﻿#EK NOTE: replaced vanilla regions

@event_in_same_scheme_cooldown_years_value = 2

@laamp_base_contract_schemes_on_going_duel_diff_t1_value = medium_skill_rating
@laamp_base_contract_schemes_on_going_duel_diff_t2_value = decent_skill_rating
@laamp_base_contract_schemes_on_going_duel_diff_t3_value = high_skill_rating

@laamp_base_contract_schemes_duel_stress_wager_value = 30

@laamp_base_contract_schemes_0551_minimum_skill_value = high_skill_rating
@laamp_base_contract_schemes_1004_gallowsbait_xp_min_value = 25
@laamp_base_contract_schemes_1004_gallowsbait_xp_max_value = 55
@laamp_base_contract_schemes_1301_ai_min_prowess_value = 15
@laamp_base_contract_schemes_1782_min_gold_value = 50
@laamp_base_contract_schemes_2311_ai_weight_threshold_value = 35
@laamp_base_contract_schemes_2541_intrigue_threshold_value = extremely_high_skill_rating
@laamp_base_contract_schemes_2661_stewardship_threshold_value = extremely_high_skill_rating
@laamp_base_contract_schemes_2661_sacrifice_skill_threshold_value = decent_skill_rating
@laamp_base_contract_schemes_2671_prowess_gain_value = 1
@laamp_base_contract_schemes_3661_martial_threshold_value = extremely_high_skill_rating
@laamp_base_contract_schemes_3661_prowess_threshold_value = very_high_skill_rating
@laamp_base_contract_schemes_5901_min_gold_value = 50

namespace = laamp_base_contract_schemes

##################################################
# #Contract Schemes (Diplo)
# 0001 - 0010	Regale court with stories
# 0011 - 0020	Improve ruler's reputation
# 0021 - 0030	Hobnob with local ruler
# 0031 - 0040	Paid Mediator
# 0041 - 0050	Confidence trickster
#
# #Contract Schemes (Martial)
# 1001 - 1010	Hunt criminals
# 1011 - 1020	Act as hired muscle
# 1021 - 1030	Help train local MaA
# 1031 - 1040	Garrison service
# 1041 - 1050	Ambush travellers
#
# #Contract Schemes (Stewardship)
# 2001 - 2010	Collect taxes for a third party
# 2011 - 2020	Perform a census
# 2021 - 2030	Help construct a building
# 2031 - 2040	Settle an administrative boundary dispute
# 2041 - 2050	Collect fake taxes
#
# #Contract Schemes (Intrigue)
# 3001 - 3010	Provide intelligence from your trips
# 3011 - 3020	Murder a character's rival
# 3021 - 3030	Abduct a character's rival
# 3031 - 3040	Attack the property of a character's rival
# 3041 - 3050	Heist from a ruler's treasury
#
# #Contract Schemes (Learning)
# 4001 - 4010	Copy texts for a learned ruler
# 4011 - 4020	Help settle a local theological argument
# 4021 - 4030	Create a work of learning for a ruler
# 4031 - 4040	Solicit Charity
# 4041 - 4050	Sell bogus relics
#
# #Contract Schemes (Prowess)
# 5001 - 5010	Hunt in the wilds
# 5011 - 5020	Guard merchant properties
# 5021 - 5030	Guard a local ruler at a minor event
# 5031 - 5040	Go rustling
# 5041 - 5050	Go poaching
#
##################################################










##################################################
# SCRIPTED TRIGGERS & EFFECTS

# Syncs stress lost from successfully completing a non-criminal contract scheme.
scripted_effect laamp_base_contract_schemes_acknowledge_success_stress_effect = {
	stress_impact = { arrogant = minor_stress_impact_loss }
}

# Syncs stress gained from failing a non-criminal contract scheme.
scripted_effect laamp_base_contract_schemes_acknowledge_failure_stress_effect = {
	if = {
		limit = { scope:task_contract_tier >= 2 }
		stress_impact = {
			base = miniscule_stress_impact_gain
			humble = minor_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
	}
}

# Syncs stress gained from successfully completing a non-criminal contract scheme.
scripted_effect laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = {
	stress_impact = {
		arrogant = minor_stress_impact_loss
		arbitrary = minor_stress_impact_loss
		just = medium_stress_impact_gain
	}
}

# Syncs stress gained from failing a non-criminal contract scheme.
scripted_effect laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = {
	stress_impact = {
		base = minor_stress_impact_gain
		humble = minor_stress_impact_loss
		arrogant = minor_stress_impact_gain
		just = medium_stress_impact_gain
	}
}

# Syncs arbitrary duel difficulty + rewards to the tier of a contract, so that the same effect can dish out scaling rewards/have scaling odds if you're impressing a king rather than a baron.
scripted_effect laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = {
	task_contract = {
		if = {
			limit = { task_contract_tier >= task_contract_t3_value }
			save_scope_value_as = {
				name = duel_diff
				value = @laamp_base_contract_schemes_on_going_duel_diff_t3_value
			}
			save_scope_value_as = {
				name = prestige_gain
				value = major_prestige_gain
			}
			save_scope_value_as = {
				name = piety_gain
				value = major_piety_gain
			}
			save_scope_value_as = {
				name = provisions_gain
				value = massive_provisions_gain
			}
		}
		else_if = {
			limit = { task_contract_tier >= task_contract_t2_value }
			save_scope_value_as = {
				name = duel_diff
				value = @laamp_base_contract_schemes_on_going_duel_diff_t2_value
			}
			save_scope_value_as = {
				name = prestige_gain
				value = medium_prestige_gain
			}
			save_scope_value_as = {
				name = piety_gain
				value = medium_piety_gain
			}
			save_scope_value_as = {
				name = provisions_gain
				value = major_provisions_gain
			}
		}
		else = {
			save_scope_value_as = {
				name = duel_diff
				value = @laamp_base_contract_schemes_on_going_duel_diff_t1_value
			}
			save_scope_value_as = {
				name = prestige_gain
				value = minor_prestige_gain
			}
			save_scope_value_as = {
				name = piety_gain
				value = minor_piety_gain
			}
			save_scope_value_as = {
				name = provisions_gain
				value = medium_provisions_gain 
			}
		}
	}
}











##################################################
# SETUP — DIPLO

##################################################
# Regale court with stories (setup)
# by Ewan Cowhig Croft
# 0001 - 0010
##################################################

#	Intro event.
laamp_base_contract_schemes.0001 = {
	type = character_event
	title = laamp_base_contract_schemes.0001.t
	desc = laamp_base_contract_schemes.0001.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = flirtation_left
	}
	override_background = { reference = feast }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
		scope:scheme = {
			increment_variable_effect = {
				VAR = secrecy_grace_period
				VAL = 2
			}
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.0001.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_poet
			add_agent_slot = agent_musician
			# Speed.
			add_agent_slot = agent_socialite
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.0001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_shill
			add_agent_slot = agent_poet
			add_agent_slot = agent_musician
			# Speed.
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.0001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_poet
			# Speed.
			add_agent_slot = agent_socialite
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.0002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.0002.t
	desc = laamp_base_contract_schemes.0002.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:employer
		animation = throne_room_applaud_1
	}
	override_background = { reference = feast }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_0001_success_employer_modifier
				years = 10
			}
			add_prestige = medium_prestige_gain
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.0003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.0003.t
	desc = laamp_base_contract_schemes.0003.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:employer
		animation = disappointed
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_0001_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Improve ruler's reputation (setup)
# by Ewan Cowhig Croft
# 0011 - 0020
##################################################

#	Intro event.
laamp_base_contract_schemes.0011 = {
	type = character_event
	title = laamp_base_contract_schemes.0011.t
	desc = laamp_base_contract_schemes.0011.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = chancellor
	}
	right_portrait = {
		character = scope:employer
		animation = throne_room_conversation_3
	}
	override_background = { reference = throne_room }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.0011.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_scribe
			add_agent_slot = agent_musician
			# Speed.
			add_agent_slot = agent_herald
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.0011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_scribe
			add_agent_slot = agent_musician
			# Speed.
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.0011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			# Speed.
			add_agent_slot = agent_herald
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.0012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.0012.t
	desc = laamp_base_contract_schemes.0012.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = throne_room_messenger_3
	}
	right_portrait = {
		character = scope:employer
		animation = throne_room_applaud_1
	}
	override_background = { reference = throne_room }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			# Reduce tyranny.
			if = {
				limit = { tyranny >= 1 }
				add_tyranny = major_tyranny_loss
			}
			# Else reducy strife.
			else_if = {
				limit = { strife_opinion >= 1 }
				change_strife_opinion = major_strife_loss
			}
			# Else remove potential rivals.
			else_if = {
				limit = {
					any_relation = {
						type = potential_rival
						count >= 1
						laamp_base_0011_valid_potential_rival_trigger = yes
					}
				}
				custom_tooltip = {
					text = laamp_base_0011.tt.success_standard.employer_reward.remove_potential_rivals
					every_relation = {
						type = potential_rival
						limit = { laamp_base_0011_valid_potential_rival_trigger = yes }
						remove_relation_potential_rival = prev
					}
				}
			}
			# Give some prestige whatever else we do.
			add_prestige = medium_prestige_gain
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0012.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.0013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.0013.t
	desc = laamp_base_contract_schemes.0013.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = beg
	}
	right_portrait = {
		character = scope:employer
		animation = disappointed
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			random_list = {
				33 = {
					trigger = { highest_held_title_tier >= tier_county }
					add_tyranny = medium_tyranny_gain
				}
				33 = {
					trigger = { is_independent_ruler = no }
					change_strife_opinion = medium_strife_gain
				}
				33 = { add_prestige = medium_prestige_loss }
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0013.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Hobnob with local ruler (setup)
# by Ewan Cowhig Croft
# 0021 - 0030
##################################################

#	Intro event.
laamp_base_contract_schemes.0021 = {
	type = character_event
	title = laamp_base_contract_schemes.0021.t
	desc = laamp_base_contract_schemes.0021.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = throne_room_conversation_1
	}
	right_portrait = {
		character = scope:employer
		animation = flirtation_left
	}
	override_background = { reference = sitting_room }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.0021.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_shill
			# Speed.
			add_agent_slot = agent_herald
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.0021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_shill
			add_agent_slot = agent_bodyguard
			# Speed.
			add_agent_slot = agent_herald
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.0021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			# Speed.
			add_agent_slot = agent_herald
			add_agent_slot = agent_herald
			add_agent_slot = agent_socialite
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.0022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.0022.t
	desc = laamp_base_contract_schemes.0022.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = hero_flex
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = sitting_room }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = { add_stress = major_stress_loss }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0022.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.0023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.0023.t
	desc = laamp_base_contract_schemes.0023.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = disappointed
	}
	right_portrait = {
		character = scope:employer
		animation = dismissal
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = { add_stress = medium_stress_gain }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0023.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Paid Mediator (setup)
# by Ewan Cowhig Croft
# 0031 - 0040
##################################################

#	Intro event.
laamp_base_contract_schemes.0031 = {
	type = character_event
	title = laamp_base_contract_schemes.0031.t
	desc = laamp_base_contract_schemes.0031.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	override_background = { reference = alley_day }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.0031.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_scribe
			# Speed.
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_herald
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.0031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_scribe
			add_agent_slot = agent_scribe
			# Speed.
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.0031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			# Speed.
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_herald
			add_agent_slot = agent_infiltrator
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.0032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.0032.t
	desc = laamp_base_contract_schemes.0032.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = throne_room_applaud_1
	}
	override_background = { reference = alley_day }

	immediate = {
		# Are we a scheme?
		if = {
			limit = { exists = scope:scheme }
			laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
			random_list = {
				67 = {
					scope:scheme.task_contract = { complete_task_contract = success_standard }
				}
				33 = {
					scope:scheme.task_contract = { complete_task_contract = success_critical }
				}
			}
			# Employer outcome.
			scope:employer = {
				add_character_modifier = {
					modifier = laamp_base_0031_success_employer_modifier
					years = 10
				}
				add_prestige = medium_prestige_gain
			}
			# And wrap things up.
			scope:scheme ?= { end_scheme = yes }
		}
		# Or a mini-game?
		else = {
			scope:task_contract = {
				task_contract_employer = { save_scope_as = employer }
				save_scope_value_as = {
					name = task_contract_tier
					value = task_contract_tier
				}
				if = {
					limit = { exists = scope:exceptional_achieved }
					complete_task_contract = success_critical
				}
				else = { complete_task_contract = success_standard }
			}
			# Employer outcome.
			scope:employer = {
				add_character_modifier = {
					modifier = laamp_base_0031_success_employer_modifier
					years = 10
				}
				add_prestige = medium_prestige_gain
			}
		}
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.0033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.0033.t
	desc = laamp_base_contract_schemes.0033.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = beg
	}
	right_portrait = {
		character = scope:employer
		animation = disappointed
	}
	override_background = { reference = alley_day }

	immediate = {
		# Are we a scheme?
		if = {
			limit = { exists = scope:scheme }
			laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
			scope:scheme.task_contract = { complete_task_contract = failure_standard }
			# Employer outcome.
			scope:employer = {
				add_character_modifier = {
					modifier = laamp_base_0031_failure_employer_modifier
					years = 10
				}
				add_prestige = medium_prestige_loss
			}
			# And wrap things up.
			scope:scheme ?= { end_scheme = yes }
		}
		# Or a mini-game?
		else = {
			scope:task_contract = {
				task_contract_employer = { save_scope_as = employer }
				save_scope_value_as = {
					name = task_contract_tier
					value = task_contract_tier
				}
				complete_task_contract = failure_standard
			}
			scope:employer = {
				add_character_modifier = {
					modifier = laamp_base_0031_failure_employer_modifier
					years = 10
				}
				add_prestige = medium_prestige_loss
			}
		}
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_0034_distribute_province_modifiers_effect = {
	random_list = {
		# Diplomacy + martial + stewardship
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_stewardship_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_stewardship_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.martial
				always = yes
			}
			modifier = {
				add = root.stewardship
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_stewardship_modifier
					years = 20
				}
			}
		}
		# Diplomacy + martial + intrigue
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_intrigue_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_intrigue_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.martial
				always = yes
			}
			modifier = {
				add = root.intrigue
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_intrigue_modifier
					years = 20
				}
			}
		}
		# Diplomacy + martial + learning
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_learning_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_learning_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.martial
				always = yes
			}
			modifier = {
				add = root.learning
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_learning_modifier
					years = 20
				}
			}
		}
		# Diplomacy + martial + prowess
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_prowess_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_prowess_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.martial
				always = yes
			}
			modifier = {
				add = root.prowess
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_prowess_modifier
					years = 20
				}
			}
		}
		# Diplomacy + stewardship + intrigue
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_intrigue_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_intrigue_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.stewardship
				always = yes
			}
			modifier = {
				add = root.intrigue
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_intrigue_modifier
					years = 20
				}
			}
		}
		# Diplomacy + stewardship + learning
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_learning_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_learning_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.stewardship
				always = yes
			}
			modifier = {
				add = root.learning
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_learning_modifier
					years = 20
				}
			}
		}
		# Diplomacy + stewardship + prowess
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_prowess_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_prowess_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.stewardship
				always = yes
			}
			modifier = {
				add = root.prowess
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_prowess_modifier
					years = 20
				}
			}
		}
		# Diplomacy + intrigue + learning
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_learning_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_learning_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.intrigue
				always = yes
			}
			modifier = {
				add = root.learning
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_learning_modifier
					years = 20
				}
			}
		}
		# Diplomacy + intrigue + prowess
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_prowess_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_prowess_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.intrigue
				always = yes
			}
			modifier = {
				add = root.prowess
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_prowess_modifier
					years = 20
				}
			}
		}
		# Diplomacy + learning + prowess
		1 = {
			trigger = {
				NOR = {
					scope:destination_1.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_learning_prowess_modifier }
					AND = {
						exists = scope:destination_2
						scope:destination_2.title_province = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_learning_prowess_modifier }
					}
				}
			}
			# Weight up a bit for what we're actually good at.
			modifier = {
				add = root.learning
				always = yes
			}
			modifier = {
				add = root.prowess
				always = yes
			}
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_learning_prowess_modifier
					years = 20
				}
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_0034_organise_travel_effect = {
	start_travel_plan = {
		destination = scope:destination_3.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_1.title_province
		on_arrival_on_action = laamp_base_0031_contract_scheme_arrival_events
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.0035
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.0034 = {
	type = character_event
	title = laamp_base_contract_schemes.0034.t
	desc = laamp_base_contract_schemes.0034.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = boredom
	}
	override_background = { reference = wilderness }

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			ordered_sub_realm_county = {
				order_by = {
					value = county_opinion
					multiply = -1
				}
				max = 3
				check_range_bounds = no
				add_to_list = destination_counties_list
			}
			ordered_in_list = {
				list = destination_counties_list
				order_by = "squared_distance(prev.capital_province)"
				max = 3
				check_range_bounds = no
				if = {
					limit = {
						NOT = { exists = scope:destination_1 }
					}
					save_scope_as = destination_1
					laamp_base_contract_schemes_0034_distribute_province_modifiers_effect = yes
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							exists = scope:destination_2
						}
					}
					save_scope_as = destination_2
					laamp_base_contract_schemes_0034_distribute_province_modifiers_effect = yes
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							exists = scope:destination_3
						}
					}
					save_scope_as = destination_3
					laamp_base_contract_schemes_0034_distribute_province_modifiers_effect = yes
				}
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.0034.a

		custom_tooltip = travel.stationary_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.0034.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.0034.tt.explanation
		laamp_base_contract_schemes_0034_organise_travel_effect = {
			DOMICILE = no
			RETURN = yes
			EVENT_FIRE = all_but_last
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.0034.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.0034.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.0034.tt.explanation
		laamp_base_contract_schemes_0034_organise_travel_effect = {
			DOMICILE = yes
			RETURN = no
			EVENT_FIRE = all
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.0035 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		send_interface_message = {
			type = diplo_contract_scheme_invalidated_message
			title = contract_invalidated_title
			desc = contract_invalidated_desc
		}
	}
}

##################################################
# Confidence trickster (setup)
# by Ewan Cowhig Croft
# 0041 - 0050
##################################################

#	Intro event.
laamp_base_contract_schemes.0041 = {
	type = character_event
	title = laamp_base_contract_schemes.0041.t
	desc = laamp_base_contract_schemes.0041.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = feast }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.0041.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_thief
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.0041.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_thief
			add_agent_slot = agent_tumbler
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.0041.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.0042 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.0042.t
	desc = laamp_base_contract_schemes.0042.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:employer
		animation = throne_room_applaud_1
	}
	override_background = { reference = feast }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_0041_success_employer_modifier
				years = 10
			}
			add_prestige = major_prestige_loss
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0042.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.0043 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.0043.t
	desc = laamp_base_contract_schemes.0043.desc
	theme = diplomacy
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = feast }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_0041_failure_employer_modifier
				years = 10
			}
			add_prestige = medium_prestige_gain
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.0043.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = yes
	}
}

##################################################
# EXTRA — DIPLOMACY

##################################################
# Regale court with stories (on-going)
# by Ewan Cowhig Croft
# 0301 - 0420
##################################################

scripted_effect laamp_base_contract_schemes_0301_apply_rewards_effect = {
	add_prestige = scope:prestige_gain
	reverse_add_opinion = {
		target = scope:target
		modifier = impressed_opinion
		opinion = 20
	}
}

scripted_effect laamp_base_contract_schemes_0301_apply_penalties_effect = {
	scope:scheme = {
		add_scheme_modifier = { type = laamp_base_contract_schemes_0301_doubtful_stories_modifier }
	}
	reverse_add_opinion = {
		target = scope:target
		modifier = liar_opinion
		opinion = -20
	}
}

#	Tell stories according to your prestige level.
laamp_base_contract_schemes.0301 = {
	type = character_event
	title = laamp_base_contract_schemes.0301.t
	desc = laamp_base_contract_schemes.0301.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:target
		animation = admiration
	}
	override_background = { reference = feast_event }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		scope:scheme = {
			NOR = {
				has_variable = had_event_laamp_base_contract_scheme_0301
				has_scheme_modifier = laamp_base_contract_schemes_0301_doubtful_stories_modifier
			}
		}
	}

	immediate = {
		scope:scheme = {
			# Set our per-scheme cooldown.
			set_variable = {
				name = had_event_laamp_base_contract_scheme_0301
				years = 2
			}
			# Set up our skill duel difficulty.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
	}

	# Diplo-duel for a good result.
	option = {
		name = laamp_base_contract_schemes.0301.a
		
		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# Your stories impress.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0301.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0301.a.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0301_apply_rewards_effect = yes
				}
			}
			# Your stories are lame.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0301.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0301.a.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0301_apply_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Random roll it, with the odds going up or down according to your prestige level.
	option = {
		name = laamp_base_contract_schemes.0301.b
		flavor = laamp_base_contract_schemes.0301.b.f
		reason = prestige_level

		random_list = {
			0 = {
				desc = laamp_base_contract_schemes.0301.b.tt.success
				modifier = {
					add = 10
					prestige_level <= 0
				}
				modifier = {
					add = 20
					prestige_level = 1
				}
				modifier = {
					add = 40
					prestige_level = 2
				}
				modifier = {
					add = 60
					prestige_level = 3
				}
				modifier = {
					add = 80
					prestige_level = 4
				}
				modifier = {
					add = 100
					prestige_level >= 5
				}
				laamp_base_contract_schemes_0301_apply_rewards_effect = yes
			}
			0 = {
				desc = laamp_base_contract_schemes.0301.b.tt.failure
				modifier = {
					add = 90
					prestige_level <= 0
				}
				modifier = {
					add = 80
					prestige_level = 1
				}
				modifier = {
					add = 60
					prestige_level = 2
				}
				modifier = {
					add = 40
					prestige_level = 3
				}
				modifier = {
					add = 20
					prestige_level = 4
				}
				modifier = {
					add = 0
					prestige_level >= 5
				}
				laamp_base_contract_schemes_0301_apply_penalties_effect = yes
			}
		}

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = prestige_level
					multiply = 30
					# So maxed prestige level = +150.
				}
				always = yes
			}
		}
	}
	
	# Intrigue duel for a good result.
	option = {
		name = laamp_base_contract_schemes.0301.c
		
		duel = {
			skill = intrigue
			value = scope:duel_diff
			# Your lies deceive.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0301.c.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0301.c.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0301_apply_rewards_effect = yes
				}
			}
			# They see right through you.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0301.c.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0301.c.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0301_apply_penalties_effect = yes
				}
			}
		}

		stress_impact = {
			deceitful = miniscule_stress_impact_loss
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -1 }
		}
	}
	
	# Back out of the conversation.
	option = {
		name = laamp_base_contract_schemes.0301.d
		trigger = {
			NOR = {
				has_trait = greedy
				has_trait = gluttonous
			}
		}
		
		# Stress loss is the major result here.
		stress_impact = {
			base = medium_stress_loss
			shy = major_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -1 }
		}
	}
	
	# Steal food.
	option = {
		name = laamp_base_contract_schemes.0301.e
		trigger = {
			OR = {
				has_trait = greedy
				has_trait = gluttonous
			}
		}
		trait = greedy
		trait = gluttonous

		domicile = { change_provisions = minor_provisions_gain }
		
		# Stress loss is the major result here.
		stress_impact = {
			base = medium_stress_loss
			greedy = minor_stress_impact_loss
			gluttonous = minor_stress_impact_loss
			shy = major_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -1 }
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0311_exotic_culture_trigger = {
	NOR = {
		culture = root.culture
		any_courtier_or_guest = { culture = root.culture }
		# More strenuous checks for players, who are likely to care more.
		trigger_if = {
			limit = {
				root = { is_ai = no }
			}
			any_consort = { culture = root.culture }
			any_close_or_extended_family_member = { culture = root.culture }
			any_vassal_or_below = { culture = root.culture }
			any_liege_or_above = { culture = root.culture }
			root.culture = {
				any_culture_empire = {
					add_to_temporary_list = culture_empire_list_temp
					count = all
					scope:target = {
						any_realm_de_jure_empire = { is_in_list = culture_empire_list_temp }
					}
				}
			}
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0311_exotic_faith_trigger = {
	# We use religion to handily rule out as many similar people as possible.
	NOR = {
		religion = root.religion
		any_courtier_or_guest = { religion = root.religion }
		# More strenuous checks for players, who are likely to care more.
		trigger_if = {
			limit = {
				root = { is_ai = no }
			}
			any_consort = { religion = root.religion }
			any_close_or_extended_family_member = { religion = root.religion }
			any_vassal_or_below = { religion = root.religion }
			any_liege_or_above = { religion = root.religion }
			any_realm_county = { religion = root.religion }
			any_neighboring_and_across_water_realm_same_rank_owner = {
				OR = {
					religion = root.religion
					any_liege_or_above = { religion = root.religion }
				}
			}
		}
	}
}

#	Tell stories of your exotic culture/faith.
laamp_base_contract_schemes.0311 = {
	type = character_event
	title = laamp_base_contract_schemes.0311.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:exotic_culture
					NOT = { exists = scope:exotic_faith }
				}
				desc = laamp_base_contract_schemes.0311.desc.only_exotic_culture
			}
			triggered_desc = {
				trigger = {
					exists = scope:exotic_faith
					NOT = { exists = scope:exotic_culture }
				}
				desc = laamp_base_contract_schemes.0311.desc.only_exotic_faith
			}
			desc = laamp_base_contract_schemes.0311.desc.both_exotic
		}
		desc = laamp_base_contract_schemes.0311.desc.outro
	}
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:target
		animation = personality_rational
	}
	override_background = { reference = feast_event }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0311 }
		}
		# Event-specific triggers.
		scope:target = {
			# Can't have had the outcome of this event recently.
			NOT = { has_character_modifier = laamp_base_contract_schemes_0311_likes_other_faiths_modifier }
			# We must have a validly interesting culture or faith.
			OR = {
				# Culture.
				laamp_base_contract_schemes_0311_exotic_culture_trigger = yes
				# Faith.
				laamp_base_contract_schemes_0311_exotic_faith_trigger = yes
			}
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0311
				years = @event_in_same_scheme_cooldown_years_value
			}
		}
		# Grab our exotic qualities.
		if = {
			limit = {
				scope:target = { laamp_base_contract_schemes_0311_exotic_culture_trigger = yes }
			}
			culture = { save_scope_as = exotic_culture }
		}
		if = {
			limit = {
				scope:target = { laamp_base_contract_schemes_0311_exotic_faith_trigger = yes }
			}
			faith = { save_scope_as = exotic_faith }
		}
		# Set up our skill duel difficulty.
		scope:scheme = { laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes }
	}

	# Culture: diplo-duel to impress.
	option = {
		name = laamp_base_contract_schemes.0311.a
		trigger = { exists = scope:exotic_culture }

		duel = {
			skill = diplomacy
			target = scope:target
			# Your culture sounds marvellous!
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0311.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0311.a.tt.success
					add_prestige = scope:prestige_gain
					scope:target.culture = {
						change_cultural_acceptance = {
							target = scope:exotic_culture
							value = medium_cultural_acceptance_gain
							desc = laamp_base_contract_schemes.0311.a.tt.success.cultural_acceptance
						}
					}
					reverse_add_opinion = {
						target = scope:target
						modifier = impressed_opinion
						opinion = 50
					}
				}
			}
			# What strangely ignorant barbarians...
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0311.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0311.a.tt.failure
					left_icon = scope:target
					add_stress = medium_stress_gain
					scope:target.culture = {
						change_cultural_acceptance = {
							target = scope:exotic_culture
							value = minor_cultural_acceptance_loss
							desc = laamp_base_contract_schemes.0311.a.tt.failure.cultural_acceptance
						}
					}
					reverse_add_opinion = {
						target = scope:target
						modifier = liar_opinion
						opinion = -20
					}
				}
			}
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Faith: learning duel to impress them.
	option = {
		name = laamp_base_contract_schemes.0311.b
		trigger = { exists = scope:exotic_faith }

		duel = {
			skill = learning
			target = scope:target
			# What a fascinating view!
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0311.b.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0311.b.tt.success
					left_icon = scope:target
					add_piety = scope:piety_gain
					scope:target = {
						add_opinion = {
							target = root
							modifier = impressed_opinion
							opinion = 50
						}
						add_character_modifier = {
							modifier = laamp_base_contract_schemes_0311_likes_other_faiths_modifier
							years = 20
						}
					}
				}
			}
			# How ignorant can you possibly be?
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0311.b.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0311.b.tt.failure
					left_icon = scope:target
					add_piety = minor_piety_loss
					scope:target = {
						add_character_modifier = {
							modifier = laamp_base_contract_schemes_0311_hates_other_faiths_modifier
							years = 20
						}
					}
				}
			}
		}

		stress_impact = {
			zealous = miniscule_stress_impact_loss
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_zeal = 1 }
		}
	}

	# Intrigue duel to just fabricate stuff.
	option = {
		name = laamp_base_contract_schemes.0311.c

		duel = {
			skill = intrigue
			value = high_skill_rating
			# Easy as pie.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0311.c.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0311.c.tt.success
					left_icon = scope:target
					add_prestige = {
						value = scope:prestige_gain
						multiply = 0.5
						ceiling = yes
					}
					reverse_add_opinion = {
						target = scope:target
						modifier = impressed_opinion
						opinion = 25
					}
				}
			}
			# No one believes you.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0311.c.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0311.c.tt.failure
					left_icon = scope:target
					add_stress = @laamp_base_contract_schemes_duel_stress_wager_value
					reverse_add_opinion = {
						target = scope:target
						modifier = liar_opinion
						opinion = -20
					}
				}
			}
		}

		stress_impact = {
			deceitful = miniscule_stress_impact_loss
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -1 }
		}
	}

	# Fob them off.
	option = {
		name = laamp_base_contract_schemes.0311.d
		
		reverse_add_opinion = {
			target = scope:target
			modifier = insult_opinion
			opinion = -10
		}
		add_prestige = minor_prestige_gain

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -1 }
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0321_valid_impressionable_courtier_trigger = {
	# Has some kind of personal indicator for running away to join a laamp.
	OR = {
		has_trait = trusting
		has_trait = brave
		has_trait = honest
		has_trait = gregarious
		has_trait = eccentric
		AND = {
			has_trait = fickle
			has_trait = arbitrary
		}
		has_any_good_relationship_with_character_trigger = { CHARACTER = root }
	}
	# And no mental blocks.
	NOR = {
		has_trait = paranoid
		has_trait = craven
		has_trait = shy
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
	}
	# Plus make sure they're valid for all the usual sensible stuff.
	is_adult = yes
	OR = {
		is_married = no
		AND = {
			is_female = yes
			matrilinear_marriage = yes
		}
		AND = {
			is_male = yes
			patrilinear_marriage = yes
		}
	}
	NOR = {
		is_child_of = scope:target
		scope:target.player_heir ?= this
	}
}

scripted_effect laamp_base_contract_schemes_0321_transfer_chosen_courtier_effect = {
	add_courtier = $COURTIER_CHOSEN$
	$REJECTED_1$ ?= {
		add_opinion = {
			target = root
			modifier = disappointed_opinion
			opinion = -30
		}
		hidden_effect = {
			remove_opinion = {
				target = root
				modifier = impressed_opinion
			}
		}
	}
	$REJECTED_2$ ?= {
		add_opinion = {
			target = root
			modifier = disappointed_opinion
			opinion = -30
		}
		hidden_effect = {
			remove_opinion = {
				target = root
				modifier = impressed_opinion
			}
		}
	}
}

#	Impressionable courtier wants to join.
laamp_base_contract_schemes.0321 = {
	type = character_event
	title = laamp_base_contract_schemes.0321.t
	desc = {
		desc = laamp_base_contract_schemes.0321.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:courtier_3 }
				desc = laamp_base_contract_schemes.0321.desc.three_courtiers
			}
			triggered_desc = {
				trigger = { exists = scope:courtier_2 }
				desc = laamp_base_contract_schemes.0321.desc.two_courtiers
			}
			desc = laamp_base_contract_schemes.0321.desc.one_courtier
		}
	}
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:courtier_1
		animation = love
	}
	lower_left_portrait = scope:target
	lower_center_portrait = scope:courtier_2
	lower_right_portrait = scope:courtier_3
	override_background = { reference = corridor_day }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0321 }
		}
		# Event-specific checks.
		scope:target = {
			any_courtier_or_guest = { laamp_base_contract_schemes_0321_valid_impressionable_courtier_trigger = yes }
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0321
				years = @event_in_same_scheme_cooldown_years_value
			}
		}
		scope:target = {
			ordered_courtier_or_guest = {
				limit = { laamp_base_contract_schemes_0321_valid_impressionable_courtier_trigger = yes }
				max = 3
				check_range_bounds = no
				order_by = {
					if = {
						limit = {
							highest_skill = diplomacy
							diplomacy >= prowess
						}
						add = diplomacy
					}
					else_if = {
						limit = {
							highest_skill = martial
							martial >= prowess
						}
						add = martial
					}
					else_if = {
						limit = {
							highest_skill = stewardship
							stewardship >= prowess
						}
						add = stewardship
					}
					else_if = {
						limit = {
							highest_skill = intrigue
							intrigue >= prowess
						}
						add = intrigue
					}
					else_if = {
						limit = {
							highest_skill = learning
							learning >= prowess
						}
						add = learning
					}
					else = { add = prowess }
				}
				if = {
					limit = {
						NOT = { exists = scope:courtier_1 }
					}
					save_scope_as = courtier_1
					add_opinion = {
						target = root
						modifier = impressed_opinion
						opinion = 100
					}
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:courtier_1
							exists = scope:courtier_2
						}
					}
					save_scope_as = courtier_2
					add_opinion = {
						target = root
						modifier = impressed_opinion
						opinion = 100
					}
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:courtier_1
							this = scope:courtier_2
							exists = scope:courtier_3
						}
					}
					save_scope_as = courtier_3
					add_opinion = {
						target = root
						modifier = impressed_opinion
						opinion = 100
					}
				}
			}
		}
	}

	# We'll take scope:courtier_1.
	option = {
		name = laamp_base_contract_schemes.0321.a

		laamp_base_contract_schemes_0321_transfer_chosen_courtier_effect = {
			COURTIER_CHOSEN = scope:courtier_1
			REJECTED_1 = scope:courtier_2
			REJECTED_2 = scope:courtier_3
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
			opinion_modifier = { opinion_target = scope:courtier_1 }
		}
	}
	
	# Perhaps scope:courtier_2.
	option = {
		name = laamp_base_contract_schemes.0321.b
		trigger = { exists = scope:courtier_2 }

		laamp_base_contract_schemes_0321_transfer_chosen_courtier_effect = {
			COURTIER_CHOSEN = scope:courtier_2
			REJECTED_1 = scope:courtier_1
			REJECTED_2 = scope:courtier_3
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
			opinion_modifier = { opinion_target = scope:courtier_2 }
		}
	}
	
	# Scope:courtier_3, please.
	option = {
		name = laamp_base_contract_schemes.0321.c
		trigger = { exists = scope:courtier_3 }

		laamp_base_contract_schemes_0321_transfer_chosen_courtier_effect = {
			COURTIER_CHOSEN = scope:courtier_3
			REJECTED_1 = scope:courtier_1
			REJECTED_2 = scope:courtier_2
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
			opinion_modifier = { opinion_target = scope:courtier_3 }
		}
	}
	
	# Sadistic: _You_? Surely you jest!
	option = {
		name = laamp_base_contract_schemes.0321.d
		trigger = { has_trait = sadistic }
		trait = sadistic

		scope:courtier_1 = {
			add_opinion = {
				target = root
				modifier = hurt_opinion
				opinion = -50
			}
			add_stress = massive_stress_gain
			hidden_effect = {
				remove_opinion = {
					target = root
					modifier = impressed_opinion
				}
			}
		}
		scope:courtier_2 ?= {
			add_opinion = {
				target = root
				modifier = hurt_opinion
				opinion = -50
			}
			add_stress = massive_stress_gain
			hidden_effect = {
				remove_opinion = {
					target = root
					modifier = impressed_opinion
				}
			}
		}
		scope:courtier_3 ?= {
			add_opinion = {
				target = root
				modifier = hurt_opinion
				opinion = -50
			}
			add_stress = massive_stress_gain
			hidden_effect = {
				remove_opinion = {
					target = root
					modifier = impressed_opinion
				}
			}
		}

		stress_impact = {
			sadistic = massive_stress_impact_loss
			shy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Alas, our company is full.
	option = {
		name = laamp_base_contract_schemes.0321.e
		trigger = {
			NOT = { has_trait = sadistic }
		}

		scope:courtier_1 = {
			add_opinion = {
				target = root
				modifier = hurt_opinion
				opinion = -10
			}
			hidden_effect = {
				remove_opinion = {
					target = root
					modifier = impressed_opinion
				}
			}
		}
		scope:courtier_2 ?= {
			add_opinion = {
				target = root
				modifier = hurt_opinion
				opinion = -10
			}
			hidden_effect = {
				remove_opinion = {
					target = root
					modifier = impressed_opinion
				}
			}
		}
		scope:courtier_3 ?= {
			add_opinion = {
				target = root
				modifier = hurt_opinion
				opinion = -10
			}
			hidden_effect = {
				remove_opinion = {
					target = root
					modifier = impressed_opinion
				}
			}
		}

		stress_impact = {
			shy = medium_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
}

scripted_effect laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = {
	add_prestige = scope:prestige_gain
	reverse_add_opinion = {
		target = scope:target
		modifier = $OPINION_TYPE$
		opinion = 20
	}
}

scripted_effect laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = {
	add_stress = @laamp_base_contract_schemes_duel_stress_wager_value
	reverse_add_opinion = {
		target = scope:target
		modifier = reputation_opinion
		opinion = -20
	}
}

#	Tell stories derived from camp purpose.
laamp_base_contract_schemes.0331 = {
	type = character_event
	title = laamp_base_contract_schemes.0331.t
	desc = laamp_base_contract_schemes.0331.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:target
		animation = throne_room_applaud_1
	}
	override_background = { reference = feast_event }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0331 }
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0331
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Set up our difficulties.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
	}

	# Stock diplo duel.
	option = {
		name = laamp_base_contract_schemes.0331.a
		
		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# You convince them!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.a.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = impressed_opinion }
				}
			}
			# They remain unimpressed.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.a.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = diplomacy
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Wanderers: 50:50 random list.
	option = {
		name = laamp_base_contract_schemes.0331.b
		trigger = { has_realm_law = camp_purpose_wanderers }
		reason = purpose_wanderers

		random_list = {
			50 = {
				desc = laamp_base_contract_schemes.0331.b.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.b.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = stories_of_the_road_opinion }
				}
			}
			50 = {
				desc = laamp_base_contract_schemes.0331.b.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.b.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -1 }
		}
	}
	
	# Mercenaries: combined martial-prowess duel.
	option = {
		name = laamp_base_contract_schemes.0331.c
		trigger = { has_realm_law = camp_purpose_mercenaries }
		reason = purpose_mercenaries

		duel = {
			skills = { martial prowess }
			value = scope:duel_diff
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.c.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.c.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = stories_of_strength_opinion }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.c.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.c.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 2 }
		}
	}
	
	# Scholars: straight learning duel.
	option = {
		name = laamp_base_contract_schemes.0331.d
		trigger = { has_realm_law = camp_purpose_scholars }
		reason = purpose_scholars

		duel = {
			skill = learning
			value = scope:duel_diff
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.d.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.d.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = teller_of_learned_parables_opinion }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.d.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.d.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 2 }
		}
	}
	
	# Explorers: combined diplo-learning duel.
	option = {
		name = laamp_base_contract_schemes.0331.e
		trigger = { has_realm_law = camp_purpose_explorers }
		reason = purpose_explorers

		duel = {
			skills = { diplomacy learning }
			value = scope:duel_diff
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.e.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.e.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = teller_of_exotic_myths_opinion }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.e.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.e.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 2 }
		}
	}
	
	# Brigands: combined intrigue-prowess duel.
	option = {
		name = laamp_base_contract_schemes.0331.f
		trigger = { has_realm_law = camp_purpose_brigands }
		reason = purpose_brigands

		duel = {
			skills = { intrigue prowess }
			value = scope:duel_diff
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.f.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.f.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = teller_of_salacious_tales_opinion }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.f.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.f.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_compassion = -2 }
		}
	}
	
	# Legitimists: combined diplo-martial duel.
	option = {
		name = laamp_base_contract_schemes.0331.g
		trigger = { has_realm_law = camp_purpose_legitimists }
		reason = purpose_legitimists

		duel = {
			skills = { diplomacy martial }
			value = scope:duel_diff
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.g.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0331.g.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_rewards_effect = { OPINION_TYPE = stories_of_righteous_return_opinion }
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0331.g.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0331.g.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0331_distribute_standard_penalties_effect = yes
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_vengefulness = 2 }
		}
	}
	
	# Forgo the opportunity.
	option = {
		name = laamp_base_contract_schemes.0331.h
		
		reverse_add_opinion = {
			target = scope:target
			modifier = disappointed_opinion
			opinion = -15
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
}

##################################################
# Hobnob with local ruler (on-going)
# by Ewan Cowhig Croft
# 0541 - 0660
##################################################

scripted_effect laamp_base_contract_schemes_0541_higher_skill_duel_effect = {
	duel = {
		skill = $SKILL$
		value = scope:duel_diff
		# Your skills impress them.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0541.duel.tt.success
			send_interface_toast = {
				type = event_generic_good
				title = laamp_base_contract_schemes.0541.duel.tt.success
				left_icon = scope:target
				add_prestige = scope:prestige_gain
				reverse_add_opinion = {
					target = scope:target
					modifier = impressed_opinion
					opinion = 20
				}
			}
		}
		# You bore them.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0541.duel.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.0541.duel.tt.failure
				left_icon = scope:target
				add_stress = @laamp_base_contract_schemes_duel_stress_wager_value
				reverse_add_opinion = {
					target = scope:target
					modifier = impressed_opinion
					opinion = -20
				}
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_0541_lower_skill_duel_effect = {
	duel = {
		skill = $SKILL$
		value = scope:duel_diff
		# Your skills impress them.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0541.duel.tt.success
			send_interface_toast = {
				type = event_generic_good
				title = laamp_base_contract_schemes.0541.duel.tt.success
				left_icon = scope:target
				add_prestige = {
					value = scope:prestige_gain
					multiply = 1.5
					ceiling = yes
				}
				reverse_add_opinion = {
					target = scope:target
					modifier = impressed_opinion
					opinion = 20
				}
			}
		}
		# You bore them.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0541.duel.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.0541.duel.tt.failure
				left_icon = scope:target
				add_stress = @laamp_base_contract_schemes_duel_stress_wager_value
				reverse_add_opinion = {
					target = scope:target
					modifier = impressed_opinion
					opinion = -20
				}
			}
		}
	}
}

#	Use personal skill to impress.
laamp_base_contract_schemes.0541 = {
	type = character_event
	title = laamp_base_contract_schemes.0541.t
	desc = laamp_base_contract_schemes.0541.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:target
		animation = boredom
	}
	override_background = { reference = courtyard_scope }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0541 }
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0541
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Set up our skill duel difficulty.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
		# And our background scope.
		scope:target = { save_scope_as = background_courtyard_scope }
		# Figure out our relevant skills.
		## Highest
		### Diplomacy
		if = {
			limit = {
				highest_skill = diplomacy
				diplomacy >= prowess
			}
			save_scope_value_as = {
				name = highest_skill
				value = flag:diplomacy
			}
		}
		### Martial
		else_if = {
			limit = {
				highest_skill = martial
				martial >= prowess
			}
			save_scope_value_as = {
				name = highest_skill
				value = flag:martial
			}
		}
		### Stewardship
		else_if = {
			limit = {
				highest_skill = stewardship
				stewardship >= prowess
			}
			save_scope_value_as = {
				name = highest_skill
				value = flag:stewardship
			}
		}
		### Intrigue
		else_if = {
			limit = {
				highest_skill = intrigue
				intrigue >= prowess
			}
			save_scope_value_as = {
				name = highest_skill
				value = flag:intrigue
			}
		}
		### Learning
		else_if = {
			limit = {
				highest_skill = learning
				learning >= prowess
			}
			save_scope_value_as = {
				name = highest_skill
				value = flag:learning
			}
		}
		### Prowess
		else = {
			save_scope_value_as = {
				name = highest_skill
				value = flag:prowess
			}
		}
		## Lowest
		### Diplomacy
		if = {
			limit = {
				diplomacy <= martial
				diplomacy <= stewardship
				diplomacy <= intrigue
				diplomacy <= learning
				diplomacy <= prowess
			}
			save_scope_value_as = {
				name = lowest_skill
				value = flag:diplomacy
			}
		}
		### Martial
		else_if = {
			limit = {
				martial <= diplomacy
				martial <= stewardship
				martial <= intrigue
				martial <= learning
				martial <= prowess
			}
			save_scope_value_as = {
				name = lowest_skill
				value = flag:martial
			}
		}
		### Stewardship
		else_if = {
			limit = {
				stewardship <= diplomacy
				stewardship <= martial
				stewardship <= intrigue
				stewardship <= learning
				stewardship <= prowess
			}
			save_scope_value_as = {
				name = lowest_skill
				value = flag:stewardship
			}
		}
		### Intrigue
		else_if = {
			limit = {
				intrigue <= diplomacy
				intrigue <= martial
				intrigue <= stewardship
				intrigue <= learning
				intrigue <= prowess
			}
			save_scope_value_as = {
				name = lowest_skill
				value = flag:intrigue
			}
		}
		### Learning
		else_if = {
			limit = {
				learning <= diplomacy
				learning <= martial
				learning <= stewardship
				learning <= intrigue
				learning <= prowess
			}
			save_scope_value_as = {
				name = lowest_skill
				value = flag:learning
			}
		}
		### Prowess
		else = {
			save_scope_value_as = {
				name = lowest_skill
				value = flag:prowess
			}
		}
	}

	# Highest skill duel: diplomacy.
	option = {
		name = laamp_base_contract_schemes.0541.a
		flavor = laamp_base_contract_schemes.0541.tt.highest_skill_weaker_results
		trigger = { scope:highest_skill = flag:diplomacy }

		laamp_base_contract_schemes_0541_higher_skill_duel_effect = { SKILL = diplomacy }

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Highest skill duel: martial.
	option = {
		name = laamp_base_contract_schemes.0541.b
		flavor = laamp_base_contract_schemes.0541.tt.highest_skill_weaker_results
		trigger = { scope:highest_skill = flag:martial }

		laamp_base_contract_schemes_0541_higher_skill_duel_effect = { SKILL = martial }

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Highest skill duel: stewardship.
	option = {
		name = laamp_base_contract_schemes.0541.c
		flavor = laamp_base_contract_schemes.0541.tt.highest_skill_weaker_results
		trigger = { scope:highest_skill = flag:stewardship }

		laamp_base_contract_schemes_0541_higher_skill_duel_effect = { SKILL = stewardship }

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Highest skill duel: intrigue.
	option = {
		name = laamp_base_contract_schemes.0541.d
		flavor = laamp_base_contract_schemes.0541.tt.highest_skill_weaker_results
		trigger = { scope:highest_skill = flag:intrigue }

		laamp_base_contract_schemes_0541_higher_skill_duel_effect = { SKILL = intrigue }

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Highest skill duel: learning.
	option = {
		name = laamp_base_contract_schemes.0541.e
		flavor = laamp_base_contract_schemes.0541.tt.highest_skill_weaker_results
		trigger = { scope:highest_skill = flag:learning }

		laamp_base_contract_schemes_0541_higher_skill_duel_effect = { SKILL = learning }

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Highest skill duel: prowess.
	option = {
		name = laamp_base_contract_schemes.0541.f
		flavor = laamp_base_contract_schemes.0541.tt.highest_skill_weaker_results
		trigger = { scope:highest_skill = flag:prowess }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = prowess }

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Lowest skill duel: diplomacy.
	option = {
		name = laamp_base_contract_schemes.0541.g
		flavor = laamp_base_contract_schemes.0541.tt.lowest_skill_stronger_results
		trigger = { scope:lowest_skill = flag:diplomacy }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = diplomacy }

		stress_impact = {
			humble = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Lowest skill duel: martial.
	option = {
		name = laamp_base_contract_schemes.0541.h
		flavor = laamp_base_contract_schemes.0541.tt.lowest_skill_stronger_results
		trigger = { scope:lowest_skill = flag:martial }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = martial }

		stress_impact = {
			humble = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Lowest skill duel: stewardship.
	option = {
		name = laamp_base_contract_schemes.0541.i
		flavor = laamp_base_contract_schemes.0541.tt.lowest_skill_stronger_results
		trigger = { scope:lowest_skill = flag:stewardship }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = stewardship }

		stress_impact = {
			humble = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Lowest skill duel: intrigue.
	option = {
		name = laamp_base_contract_schemes.0541.j
		flavor = laamp_base_contract_schemes.0541.tt.lowest_skill_stronger_results
		trigger = { scope:lowest_skill = flag:intrigue }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = intrigue }

		stress_impact = {
			humble = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Lowest skill duel: learning.
	option = {
		name = laamp_base_contract_schemes.0541.k
		flavor = laamp_base_contract_schemes.0541.tt.lowest_skill_stronger_results
		trigger = { scope:lowest_skill = flag:learning }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = learning }

		stress_impact = {
			humble = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Lowest skill duel: prowess.
	option = {
		name = laamp_base_contract_schemes.0541.l
		flavor = laamp_base_contract_schemes.0541.tt.lowest_skill_stronger_results
		trigger = { scope:lowest_skill = flag:prowess }

		laamp_base_contract_schemes_0541_lower_skill_duel_effect = { SKILL = prowess }

		stress_impact = {
			humble = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Remain aloof.
	option = {
		name = laamp_base_contract_schemes.0541.m
		
		add_prestige = miniscule_prestige_gain
		reverse_add_opinion = {
			target = scope:target
			modifier = mysterious_opinion
			opinion = 10
		}

		stress_impact = {
			shy = miniscule_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0551_suitable_courtier_to_challenge_trigger = {
	# Sensible minimum reqs.
	is_available_adult = yes
	location = scope:target.capital_county.title_province
	# Must be kinda good at _something_.
	OR = {
		diplomacy >= @laamp_base_contract_schemes_0551_minimum_skill_value
		martial >= @laamp_base_contract_schemes_0551_minimum_skill_value
		stewardship >= @laamp_base_contract_schemes_0551_minimum_skill_value
		intrigue >= @laamp_base_contract_schemes_0551_minimum_skill_value
		learning >= @laamp_base_contract_schemes_0551_minimum_skill_value
		prowess >= @laamp_base_contract_schemes_0551_minimum_skill_value
	}
	# And have some important position or other.
	OR = {
		is_close_family_of = scope:target
		is_consort_of = scope:target
		is_councillor_of = scope:target
		has_any_court_position = yes
	}
}

scripted_effect laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
	if = {
		limit = {
			scope:$SKILL_2$_candidate ?= this
			$SKILL_1$ >= $SKILL_2$
		}
		clear_saved_scope = $SKILL_2$_candidate
	}
	if = {
		limit = {
			scope:$SKILL_3$_candidate ?= this
			$SKILL_1$ >= $SKILL_3$
		}
		clear_saved_scope = $SKILL_3$_candidate
	}
	if = {
		limit = {
			scope:$SKILL_4$_candidate ?= this
			$SKILL_1$ >= $SKILL_4$
		}
		clear_saved_scope = $SKILL_4$_candidate
	}
	if = {
		limit = {
			scope:$SKILL_5$_candidate ?= this
			$SKILL_1$ >= $SKILL_5$
		}
		clear_saved_scope = $SKILL_5$_candidate
	}
	if = {
		limit = {
			scope:$SKILL_6$_candidate ?= this
			$SKILL_1$ >= $SKILL_6$
		}
		clear_saved_scope = $SKILL_6$_candidate
	}
}

scripted_effect laamp_base_contract_schemes_0551_roll_secondary_agents_effect = {
	random_list = {
		# Strongly prefer diplo to the others.
		100 = {
			trigger = {
				scope:diplomacy_candidate ?= {
					NOT = { is_in_list = selected_candidates_list }
				}
			}
			scope:diplomacy_candidate = { add_to_list = selected_candidates_list }
		}
		10 = {
			trigger = {
				scope:martial_candidate ?= {
					NOT = { is_in_list = selected_candidates_list }
				}
			}
			scope:martial_candidate = { add_to_list = selected_candidates_list }
		}
		10 = {
			trigger = {
				scope:stewardship_candidate ?= {
					NOT = { is_in_list = selected_candidates_list }
				}
			}
			scope:stewardship_candidate = { add_to_list = selected_candidates_list }
		}
		10 = {
			trigger = {
				scope:intrigue_candidate ?= {
					NOT = { is_in_list = selected_candidates_list }
				}
			}
			scope:intrigue_candidate = { add_to_list = selected_candidates_list }
		}
		10 = {
			trigger = {
				scope:learning_candidate ?= {
					NOT = { is_in_list = selected_candidates_list }
				}
			}
			scope:learning_candidate = { add_to_list = selected_candidates_list }
		}
		10 = {
			trigger = {
				scope:prowess_candidate ?= {
					NOT = { is_in_list = selected_candidates_list }
				}
			}
			scope:prowess_candidate = { add_to_list = selected_candidates_list }
		}
	}
}

scripted_effect laamp_base_contract_schemes_0551_duel_candidate_effect = {
	duel = {
		skill = $SKILL$
		target = $CANDIDATE$
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0551.duel.tt.success
			send_interface_toast = {
				type = event_generic_good
				title = laamp_base_contract_schemes.0551.duel.tt.success
				left_icon = $CANDIDATE$
				right_icon = scope:target
				scope:scheme = {
					add_scheme_modifier = { type = laamp_base_contract_schemes_0551_impressive_at_court_modifier }
				}
			}
		}
		# Defeat!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0551.duel.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.0551.duel.tt.failure
				left_icon = $CANDIDATE$
				right_icon = scope:target
				scope:scheme = {
					add_scheme_modifier = { type = laamp_base_contract_schemes_0551_pathetic_at_court_modifier }
				}
			}
		}
	}
}

#	Hang out with influential figures at court.
laamp_base_contract_schemes.0551 = {
	type = character_event
	title = laamp_base_contract_schemes.0551.t
	desc = laamp_base_contract_schemes.0551.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:target
		animation = dismissal
	}
	lower_left_portrait = scope:portrait_1
	lower_center_portrait = scope:portrait_2
	lower_right_portrait = scope:portrait_3
	override_background = { reference = relaxing_room_scope }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0551 }
		}
		# Event-specific checks.
		scope:scheme = {	
			NOR = {
				has_scheme_modifier = laamp_base_contract_schemes_0551_impressive_at_court_modifier
				has_scheme_modifier = laamp_base_contract_schemes_0551_pathetic_at_court_modifier
			}
		}
		scope:target = {
			any_courtier_or_guest = { laamp_base_contract_schemes_0551_suitable_courtier_to_challenge_trigger = yes }
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0551
				years = @event_in_same_scheme_cooldown_years_value
			}
		}
		scope:target = {
			save_scope_as = background_relaxing_room_scope
			# Pre-filter out our valid candidates.
			every_courtier_or_guest = {
				limit = { laamp_base_contract_schemes_0551_suitable_courtier_to_challenge_trigger = yes }
				add_to_list = courtier_processing_list
			}
		}
		# Try to grab our best candidates.
		# Diplomacy
		ordered_in_list = {
			list = courtier_processing_list
			limit = { diplomacy >= @laamp_base_contract_schemes_0551_minimum_skill_value }
			order_by = diplomacy
			save_scope_as = diplomacy_candidate
		}
		# Martial
		ordered_in_list = {
			list = courtier_processing_list
			limit = { martial >= @laamp_base_contract_schemes_0551_minimum_skill_value }
			order_by = martial
			save_scope_as = martial_candidate
		}
		# Stewardship
		ordered_in_list = {
			list = courtier_processing_list
			limit = { stewardship >= @laamp_base_contract_schemes_0551_minimum_skill_value }
			order_by = stewardship
			save_scope_as = stewardship_candidate
		}
		# Intrigue
		ordered_in_list = {
			list = courtier_processing_list
			limit = { intrigue >= @laamp_base_contract_schemes_0551_minimum_skill_value }
			order_by = intrigue
			save_scope_as = intrigue_candidate
		}
		# Learning
		ordered_in_list = {
			list = courtier_processing_list
			limit = { learning >= @laamp_base_contract_schemes_0551_minimum_skill_value }
			order_by = learning
			save_scope_as = learning_candidate
		}
		# Prowess
		ordered_in_list = {
			list = courtier_processing_list
			limit = { prowess >= @laamp_base_contract_schemes_0551_minimum_skill_value }
			order_by = prowess
			save_scope_as = prowess_candidate
		}
		# Right, now that we've got our candidates, if anyone's been picked twice, filter out their lesser skilled versions.
		scope:diplomacy_candidate ?= {
			laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
				SKILL_1 = diplomacy
				SKILL_2 = martial
				SKILL_3 = stewardship
				SKILL_4 = intrigue
				SKILL_5 = learning
				SKILL_6 = prowess
			}
		}
		scope:martial_candidate ?= {
			laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
				SKILL_1 = martial
				SKILL_2 = diplomacy
				SKILL_3 = stewardship
				SKILL_4 = intrigue
				SKILL_5 = learning
				SKILL_6 = prowess
			}
		}
		scope:stewardship_candidate ?= {
			laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
				SKILL_1 = stewardship
				SKILL_2 = diplomacy
				SKILL_3 = martial
				SKILL_4 = intrigue
				SKILL_5 = learning
				SKILL_6 = prowess
			}
		}
		scope:intrigue_candidate ?= {
			laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
				SKILL_1 = intrigue
				SKILL_2 = diplomacy
				SKILL_3 = martial
				SKILL_4 = stewardship
				SKILL_5 = learning
				SKILL_6 = prowess
			}
		}
		scope:learning_candidate ?= {
			laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
				SKILL_1 = learning
				SKILL_2 = diplomacy
				SKILL_3 = martial
				SKILL_4 = stewardship
				SKILL_5 = intrigue
				SKILL_6 = prowess
			}
		}
		scope:prowess_candidate ?= {
			laamp_base_contract_schemes_0551_process_out_overlapping_candidacies_effect = {
				SKILL_1 = prowess
				SKILL_2 = diplomacy
				SKILL_3 = martial
				SKILL_4 = stewardship
				SKILL_5 = intrigue
				SKILL_6 = learning
			}
		}
		# Finally, shake up our batch so that we only have three choices.
		laamp_base_contract_schemes_0551_roll_secondary_agents_effect = yes
		laamp_base_contract_schemes_0551_roll_secondary_agents_effect = yes
		laamp_base_contract_schemes_0551_roll_secondary_agents_effect = yes
		## And sort their portraits.
		random_in_list = {
			list = selected_candidates_list
			save_scope_as = portrait_1
		}
		random_in_list = {
			list = selected_candidates_list
			limit = {
				NOT = { this = scope:portrait_1 }
			}
			save_scope_as = portrait_2
		}
		random_in_list = {
			list = selected_candidates_list
			limit = {
				NOR = {
					this = scope:portrait_1
					this = scope:portrait_2
				}
			}
			save_scope_as = portrait_3
		}
	}

	# Duel against the diplo candidate.
	option = {
		name = laamp_base_contract_schemes.0551.a
		trigger = {
			scope:diplomacy_candidate ?= { is_in_list = selected_candidates_list }
		}

		laamp_base_contract_schemes_0551_duel_candidate_effect = {
			CANDIDATE = scope:diplomacy_candidate
			SKILL = diplomacy
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Duel against the martial candidate.
	option = {
		name = laamp_base_contract_schemes.0551.b
		trigger = {
			scope:martial_candidate ?= { is_in_list = selected_candidates_list }
		}

		laamp_base_contract_schemes_0551_duel_candidate_effect = {
			CANDIDATE = scope:martial_candidate
			SKILL = martial
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = martial
				always = yes
			}
		}
	}
	
	# Duel against the stewardship candidate.
	option = {
		name = laamp_base_contract_schemes.0551.c
		trigger = {
			scope:stewardship_candidate ?= { is_in_list = selected_candidates_list }
		}

		laamp_base_contract_schemes_0551_duel_candidate_effect = {
			CANDIDATE = scope:stewardship_candidate
			SKILL = stewardship
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
	
	# Duel against the intrigue candidate.
	option = {
		name = laamp_base_contract_schemes.0551.d
		trigger = {
			scope:intrigue_candidate ?= { is_in_list = selected_candidates_list }
		}

		laamp_base_contract_schemes_0551_duel_candidate_effect = {
			CANDIDATE = scope:intrigue_candidate
			SKILL = intrigue
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Duel against the learning candidate.
	option = {
		name = laamp_base_contract_schemes.0551.e
		trigger = {
			scope:learning_candidate ?= { is_in_list = selected_candidates_list }
		}

		laamp_base_contract_schemes_0551_duel_candidate_effect = {
			CANDIDATE = scope:learning_candidate
			SKILL = learning
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = learning
				always = yes
			}
		}
	}
	
	# Duel against the prowess candidate.
	option = {
		name = laamp_base_contract_schemes.0551.f
		trigger = {
			scope:prowess_candidate ?= { is_in_list = selected_candidates_list }
		}

		laamp_base_contract_schemes_0551_duel_candidate_effect = {
			CANDIDATE = scope:prowess_candidate
			SKILL = prowess
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = prowess
				always = yes
			}
		}
	}
	
	# Elect not to rock the boat.
	option = {
		name = laamp_base_contract_schemes.0551.g

		add_prestige = miniscule_prestige_loss

		stress_impact = {
			shy = miniscule_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -0.25 }
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0561_valid_close_character_trigger = {
	# Sensible minimum reqs.
	is_available_adult = yes
	location = scope:target.capital_county.title_province
	# Be in some position of influence.
	OR = {
		is_close_family_of = scope:target
		is_consort_of = scope:target
		has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:target }
	}
	# With decent opinion from scope:target, even if it's not mutual.
	reverse_opinion = {
		target = scope:target
		value >= 50
	}
}

#	Lean on someone important to them.
laamp_base_contract_schemes.0561 = {
	type = character_event
	title = laamp_base_contract_schemes.0561.t
	desc = laamp_base_contract_schemes.0561.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:insider
		animation = personality_honorable
	}
	lower_center_portrait = scope:target
	override_background = { reference = relaxing_room_scope }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0561 }
		}
		# Event-specific checks.
		scope:scheme = {
			NOR = {
				has_scheme_modifier = laamp_base_contract_schemes_0561_charmed_insider_modifier
				has_scheme_modifier = laamp_base_contract_schemes_0561_bored_insider_modifier
				has_scheme_modifier = laamp_base_contract_schemes_0561_bribed_insider_modifier
				has_scheme_modifier = laamp_base_contract_schemes_0561_intimidated_insider_modifier
				has_scheme_modifier = laamp_base_contract_schemes_0561_spooked_insider_modifier
			}
		}
		scope:target = {
			any_courtier_or_guest = { laamp_base_contract_schemes_0561_valid_close_character_trigger = yes }
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0561
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Set up our skill duel difficulty.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
		scope:target = {
			save_scope_as = background_relaxing_room_scope
			ordered_courtier_or_guest = {
				limit = { laamp_base_contract_schemes_0561_valid_close_character_trigger = yes }
				order_by = {
					value = "reverse_opinion(scope:target)"
					# Boost up some relations further.
					## Spouses.
					if = {
						limit = { is_spouse_of = scope:target }
						add = 10
					}
					## Player heirs.
					if = {
						limit = { is_player_heir_of = scope:target }
						add = 10
					}
					## Best friends.
					if = {
						limit = { has_relation_best_friend = scope:target }
						add = 20
					}
					## Soulmates.
					if = {
						limit = { has_relation_soulmate = scope:target }
						add = 30
					}
				}
				save_scope_as = insider
			}
		}
	}

	# Charm them.
	option = {
		name = laamp_base_contract_schemes.0561.a
		
		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0561.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0561.a.tt.success
					left_icon = scope:insider
					right_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0561_charmed_insider_modifier }
					}
					reverse_add_opinion = {
						target = scope:insider
						modifier = charmed_opinion
						opinion = 50
					}
				}
			}
			# Defeat!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0561.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0561.a.tt.failure
					left_icon = scope:insider
					right_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0561_bored_insider_modifier }
					}
					reverse_add_opinion = {
						target = scope:insider
						modifier = bored_opinion
						opinion = -20
					}
				}
			}
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
		}
	}
	
	# Bribe them.
	option = {
		name = laamp_base_contract_schemes.0561.b
		
		pay_short_term_gold = {
			target = scope:insider
			gold = medium_gold_value
		}
		scope:scheme = {
			add_scheme_modifier = { type = laamp_base_contract_schemes_0561_bribed_insider_modifier }
		}
		reverse_add_opinion = {
			target = scope:insider
			modifier = grateful_opinion
			opinion = 30
		}

		stress_impact = {
			generous = miniscule_stress_impact_loss
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_greed = -1 }
		}
	}
	
	# Higher intrigue: threaten them.
	option = {
		name = laamp_base_contract_schemes.0561.c
		trigger = { intrigue >= prowess }
		skill = intrigue

		duel = {
			skill = intrigue
			value = scope:duel_diff
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0561.c.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0561.c.tt.success
					left_icon = scope:insider
					right_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0561_intimidated_insider_modifier }
					}
					reverse_add_opinion = {
						target = scope:insider
						modifier = scared_opinion
						opinion = -20
					}
				}
			}
			# Defeat!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0561.c.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0561.c.tt.failure
					left_icon = scope:insider
					right_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0561_spooked_insider_modifier }
					}
					reverse_add_opinion = {
						target = scope:insider
						modifier = annoyed_opinion
						opinion = -50
					}
					reverse_add_opinion = {
						target = scope:target
						modifier = annoyed_opinion
						opinion = -30
					}
				}
			}
		}

		stress_impact = {
			callous = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_compassion = -1 }
		}
	}
	
	# Higher prowess: threaten them.
	option = {
		name = laamp_base_contract_schemes.0561.d
		trigger = { prowess >= intrigue }
		skill = prowess

		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0561.d.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0561.d.tt.success
					left_icon = scope:insider
					right_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0561_intimidated_insider_modifier }
					}
					reverse_add_opinion = {
						target = scope:insider
						modifier = scared_opinion
						opinion = -20
					}
				}
			}
			# Defeat!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0561.d.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0561.d.tt.failure
					left_icon = scope:insider
					right_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0561_spooked_insider_modifier }
					}
					reverse_add_opinion = {
						target = scope:insider
						modifier = annoyed_opinion
						opinion = -50
					}
					reverse_add_opinion = {
						target = scope:target
						modifier = annoyed_opinion
						opinion = -30
					}
				}
			}
		}

		stress_impact = {
			callous = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_compassion = -1 }
		}
	}
	
	# Leave well enough alone.
	option = {
		name = laamp_base_contract_schemes.0561.e
		
		reverse_add_opinion = {
			target = scope:insider
			modifier = impressed_opinion
			opinion = -10
		}

		stress_impact = {
			shy = miniscule_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -1 }
		}
	}
}


scripted_effect laamp_base_contract_schemes_0571_variable_diplo_duel_effect = {
	save_scope_value_as = {
		name = fail_on_fail
		value = $FAIL$
	}
	duel = {
		skill = diplomacy
		value = $DIFF$
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0571.duel.tt.success
			send_interface_toast = {
				type = event_generic_good
				title = laamp_base_contract_schemes.0571.duel.tt.success
				left_icon = scope:target
				scope:target = {
					pay_short_term_gold = {
						target = root
						gold = {
							value = major_gold_value
							multiply = $MULT$
						}
					}
				}
			}
		}
		# Defeat!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0571.duel.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.0571.duel.tt.failure
				left_icon = scope:target
				if = {
					limit = { scope:fail_on_fail = yes }
					random_character_active_contract = {
						limit = { has_task_contract_type = laamp_base_0021 }
						complete_task_contract = failure_standard
					}
				}
				else = {
					reverse_add_opinion = {
						target = scope:target
						modifier = annoyed_opinion
						opinion = {
							value = -5
						}
					}
				
				}
			}
		}
	}
}

#	Focus on fleecing them ahead of time.
laamp_base_contract_schemes.0571 = {
	type = character_event
	title = laamp_base_contract_schemes.0571.t
	desc = laamp_base_contract_schemes.0571.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_greedy
	}
	right_portrait = {
		character = scope:target
		animation = steward
	}
	override_background = { reference = location_study }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0571 }
		}
	}

	immediate = {
		scope:scheme = {
			# Set our per-scheme cooldown.
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0571
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Now, figure out our difficulty.
			## We use a custom effect rather than the generic here, because we're gonna do some specific scaling.
			task_contract = {
				if = {
					limit = { task_contract_tier >= task_contract_t3_value }
					save_scope_value_as = {
						name = duel_diff_low
						value = {
							value = @laamp_base_contract_schemes_on_going_duel_diff_t3_value
							add = -5
						}
					}
					save_scope_value_as = {
						name = duel_diff_medium
						value = @laamp_base_contract_schemes_on_going_duel_diff_t3_value
					}
					save_scope_value_as = {
						name = duel_diff_high
						value = {
							value = @laamp_base_contract_schemes_on_going_duel_diff_t3_value
							add = 7
						}
					}
				}
				else_if = {
					limit = { task_contract_tier >= task_contract_t2_value }
					save_scope_value_as = {
						name = duel_diff_low
						value = {
							value = @laamp_base_contract_schemes_on_going_duel_diff_t2_value
							add = -3
						}
					}
					save_scope_value_as = {
						name = duel_diff_medium
						value = @laamp_base_contract_schemes_on_going_duel_diff_t2_value
					}
					save_scope_value_as = {
						name = duel_diff_high
						value = {
							value = @laamp_base_contract_schemes_on_going_duel_diff_t2_value
							add = 3
						}
					}
				}
				else = {
					save_scope_value_as = {
						name = duel_diff_low
						value = {
							value = @laamp_base_contract_schemes_on_going_duel_diff_t1_value
							add = -2
						}
					}
					save_scope_value_as = {
						name = duel_diff_medium
						value = @laamp_base_contract_schemes_on_going_duel_diff_t1_value
					}
					save_scope_value_as = {
						name = duel_diff_high
						value = {
							value = @laamp_base_contract_schemes_on_going_duel_diff_t1_value
							add = 4
						}
					}
				}
			}
		}
	}

	# Very tricksy diplo duel.
	option = {
		name = laamp_base_contract_schemes.0571.a
		
		laamp_base_contract_schemes_0571_variable_diplo_duel_effect = {
			DIFF = scope:duel_diff_low
			MULT = 1.5
			FAIL = yes
		}

		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = major_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_boldness = 2
				ai_rationality = -1
			}
		}
	}
	
	# Tricksy diplo duel.
	option = {
		name = laamp_base_contract_schemes.0571.b
		
		laamp_base_contract_schemes_0571_variable_diplo_duel_effect = {
			DIFF = scope:duel_diff_medium
			MULT = 1
			FAIL = yes
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Safe diplo duel.
	option = {
		name = laamp_base_contract_schemes.0571.c
		
		laamp_base_contract_schemes_0571_variable_diplo_duel_effect = {
			DIFF = scope:duel_diff_high
			MULT = 0.5
			FAIL = no
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -1 }
		}
	}
	
	# Play it safe.
	option = {
		name = laamp_base_contract_schemes.0571.d
		
		reverse_add_opinion = {
			target = scope:target
			modifier = impressed_opinion
			opinion = 10
		}

		stress_impact = {
			generous = minor_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_rationality = 1
				ai_boldness = -2
			}
		}
	}
}

##################################################
# Paid Mediator
# by Ewan Cowhig Croft
# 0661 - 0780
##################################################

scripted_effect laamp_base_contract_schemes_0661_duel_success_effect = {
	send_interface_toast = {
		type = event_generic_good
		title = laamp_base_contract_schemes.0661.$SKILL$.tt.success
		switch = {
			trigger = var:laamp_base_0031_tally
			# Just notice to keep going.
			1 = { custom_tooltip = laamp_base_contract_schemes.0661.tt.need_additional_success }
			# Can tap out here if you like.
			2 = {
				custom_tooltip = laamp_base_contract_schemes.0661.tt.need_additional_success
				trigger_event = laamp_base_contract_schemes.0671
			}
			# Else, exceptional success!
			3 = {
				custom_tooltip = laamp_base_contract_schemes.0661.tt.full_success_achieved
				save_scope_value_as = {
					name = exceptional_achieved
					value = yes
				}
				trigger_event = laamp_base_contract_schemes.0032
			}
		}
		add_prestige = miniscule_prestige_gain
	}
	scope:location = {
		switch = {
			trigger = has_province_modifier
			laamp_base_0031_contract_scheme_challenge_diplomacy_martial_stewardship_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_stewardship_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_martial_intrigue_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_intrigue_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_martial_learning_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_learning_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_martial_prowess_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_prowess_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_intrigue_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_intrigue_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_learning_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_learning_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_prowess_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_prowess_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_learning_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_learning_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_prowess_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_prowess_modifier }
			laamp_base_0031_contract_scheme_challenge_diplomacy_learning_prowess_modifier = { remove_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_learning_prowess_modifier }
		}
	}
}

scripted_effect laamp_base_contract_schemes_0661_duel_generic_effect = {
	duel = {
		skill = $SKILL$
		value = scope:duel_diff
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0661.$SKILL$.tt.success
			increment_variable_effect = {
				VAR = laamp_base_0031_tally
				VAL = 1
			}
			add_character_flag = laamp_base_0031_contract_used_$SKILL$
			custom_tooltip = laamp_base_contract_schemes.0661.tt.progress_towards_success
			laamp_base_contract_schemes_0661_duel_success_effect = { SKILL = $SKILL$ }
		}
		# Defeat!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.0661.$SKILL$.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.0661.$SKILL$.tt.failure
				custom_tooltip = laamp_base_contract_schemes.0661.tt.contract_failed
				trigger_event = laamp_base_contract_schemes.0033
				return_home = yes
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_0661_setup_difficulties_effect = {
	random_character_active_contract = {
		limit = { has_task_contract_type = laamp_base_0031 }
		if = {
			limit = { task_contract_tier >= task_contract_t3_value }
			save_scope_value_as = {
				name = duel_diff
				value = @laamp_base_contract_schemes_on_going_duel_diff_t3_value
			}
		}
		else_if = {
			limit = { task_contract_tier >= task_contract_t2_value }
			save_scope_value_as = {
				name = duel_diff
				value = @laamp_base_contract_schemes_on_going_duel_diff_t2_value
			}
		}
		else = {
			save_scope_value_as = {
				name = duel_diff
				value = @laamp_base_contract_schemes_on_going_duel_diff_t1_value
			}
		}
		save_scope_as = task_contract
	}
}

#	Diplomacy + martial + stewardship
laamp_base_contract_schemes.0661 = {
	type = character_event
	title = laamp_base_contract_schemes.0661.t
	desc = laamp_base_contract_schemes.0661.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = marshal
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_stewardship_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_soldier }	
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0661.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Martial
	option = {
		name = laamp_base_contract_schemes.0661.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.martial
				NOT = { has_character_flag = laamp_base_0031_contract_used_martial }
			}
		}
		show_as_unavailable = { always = yes }
		skill = martial

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = martial }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = martial
				always = yes
			}
		}
	}
	
	# Stewardship
	option = {
		name = laamp_base_contract_schemes.0661.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.stewardship
				NOT = { has_character_flag = laamp_base_0031_contract_used_stewardship }
			}
		}
		show_as_unavailable = { always = yes }
		skill = stewardship

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = stewardship }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
}

#	Diplomacy + martial + intrigue
laamp_base_contract_schemes.0662 = {
	type = character_event
	title = laamp_base_contract_schemes.0662.t
	desc = laamp_base_contract_schemes.0662.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = spymaster
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_intrigue_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0662.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Martial
	option = {
		name = laamp_base_contract_schemes.0662.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.martial
				NOT = { has_character_flag = laamp_base_0031_contract_used_martial }
			}
		}
		show_as_unavailable = { always = yes }
		skill = martial

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = martial }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = martial
				always = yes
			}
		}
	}
	
	# Intrigue
	option = {
		name = laamp_base_contract_schemes.0662.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.intrigue
				NOT = { has_character_flag = laamp_base_0031_contract_used_intrigue }
			}
		}
		show_as_unavailable = { always = yes }
		skill = intrigue

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = intrigue }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Bandits: free MaA.
	option = {
		name = laamp_base_contract_schemes.0662.d
		trigger = { has_realm_law = camp_purpose_brigands }
		reason = purpose_brigands

		increment_variable_effect = {
			VAR = laamp_base_0031_tally
			VAL = 1
		}
		spawn_army = {
			men_at_arms = {
				type = maa_bandits
				stacks = 2
			}
			inheritable = yes
			uses_supply = no
			location = root.location
			name = ep3_bandits_army
		}
		laamp_base_contract_schemes_0661_duel_success_effect = { SKILL = intrigue }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
}

#	Diplomacy + martial + learning
laamp_base_contract_schemes.0663 = {
	type = character_event
	title = laamp_base_contract_schemes.0663.t
	desc = laamp_base_contract_schemes.0663.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = chaplain
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_learning_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0663.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Martial
	option = {
		name = laamp_base_contract_schemes.0663.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.martial
				NOT = { has_character_flag = laamp_base_0031_contract_used_martial }
			}
		}
		show_as_unavailable = { always = yes }
		skill = martial

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = martial }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = martial
				always = yes
			}
		}
	}
	
	# Learning
	option = {
		name = laamp_base_contract_schemes.0663.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.learning
				NOT = { has_character_flag = laamp_base_0031_contract_used_learning }
			}
		}
		show_as_unavailable = { always = yes }
		skill = learning

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = learning }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = learning
				always = yes
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_0664_peaceful_stress_effect = {
	stress_impact = {
		patient = miniscule_stress_impact_loss
		calm = miniscule_stress_impact_loss
		compassionate = miniscule_stress_impact_loss
		callous = minor_stress_impact_gain
		sadistic = minor_stress_impact_gain
		impatient = minor_stress_impact_gain
	}
}

scripted_effect laamp_base_contract_schemes_0664_threatening_stress_effect = {
	stress_impact = {
		impatient = minor_stress_impact_loss
		sadistic = minor_stress_impact_loss
		callous = minor_stress_impact_loss
		compassionate = miniscule_stress_impact_gain
		calm = miniscule_stress_impact_gain
		patient = miniscule_stress_impact_gain
	}
}

#	Diplomacy + martial + prowess
laamp_base_contract_schemes.0664 = {
	type = character_event
	title = laamp_base_contract_schemes.0664.t
	desc = laamp_base_contract_schemes.0664.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = marshal
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_martial_prowess_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0664.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Martial
	option = {
		name = laamp_base_contract_schemes.0664.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.martial
				NOT = { has_character_flag = laamp_base_0031_contract_used_martial }
			}
		}
		show_as_unavailable = { always = yes }
		skill = martial

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = martial }

		laamp_base_contract_schemes_0664_threatening_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = martial
				always = yes
			}
		}
	}
	
	# Prowess
	option = {
		name = laamp_base_contract_schemes.0664.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.prowess
				NOT = { has_character_flag = laamp_base_0031_contract_used_prowess }
			}
		}
		show_as_unavailable = { always = yes }
		skill = prowess

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = prowess }

		laamp_base_contract_schemes_0664_threatening_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = prowess
				always = yes
			}
		}
	}
}

#	Diplomacy + stewardship + intrigue
laamp_base_contract_schemes.0665 = {
	type = character_event
	title = laamp_base_contract_schemes.0665.t
	desc = laamp_base_contract_schemes.0665.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = marshal
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_intrigue_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0665.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Stewardship
	option = {
		name = laamp_base_contract_schemes.0665.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.stewardship
				NOT = { has_character_flag = laamp_base_0031_contract_used_stewardship }
			}
		}
		show_as_unavailable = { always = yes }
		skill = stewardship

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = stewardship }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
	
	# Intrigue
	option = {
		name = laamp_base_contract_schemes.0665.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.intrigue
				NOT = { has_character_flag = laamp_base_0031_contract_used_intrigue }
			}
		}
		show_as_unavailable = { always = yes }
		skill = intrigue

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = intrigue }

		laamp_base_contract_schemes_0664_threatening_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
}

#	Diplomacy + stewardship + learning
laamp_base_contract_schemes.0666 = {
	type = character_event
	title = laamp_base_contract_schemes.0666.t
	desc = laamp_base_contract_schemes.0666.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = steward
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_learning_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0666.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Stewardship
	option = {
		name = laamp_base_contract_schemes.0666.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.stewardship
				NOT = { has_character_flag = laamp_base_0031_contract_used_stewardship }
			}
		}
		show_as_unavailable = { always = yes }
		skill = stewardship

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = stewardship }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
	
	# Learning
	option = {
		name = laamp_base_contract_schemes.0666.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.learning
				NOT = { has_character_flag = laamp_base_0031_contract_used_learning }
			}
		}
		show_as_unavailable = { always = yes }
		skill = learning

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = learning }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = learning
				always = yes
			}
		}
	}
}

#	Diplomacy + stewardship + prowess
laamp_base_contract_schemes.0667 = {
	type = character_event
	title = laamp_base_contract_schemes.0667.t
	desc = laamp_base_contract_schemes.0667.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = marshal
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_stewardship_prowess_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0667.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Stewardship
	option = {
		name = laamp_base_contract_schemes.0667.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.stewardship
				NOT = { has_character_flag = laamp_base_0031_contract_used_stewardship }
			}
		}
		show_as_unavailable = { always = yes }
		skill = stewardship

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = stewardship }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
	
	# Prowess
	option = {
		name = laamp_base_contract_schemes.0667.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.prowess
				NOT = { has_character_flag = laamp_base_0031_contract_used_prowess }
			}
		}
		show_as_unavailable = { always = yes }
		skill = prowess

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = prowess }

		laamp_base_contract_schemes_0664_threatening_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = prowess
				always = yes
			}
		}
	}
}

#	Diplomacy + intrigue + learning
laamp_base_contract_schemes.0668 = {
	type = character_event
	title = laamp_base_contract_schemes.0668.t
	desc = laamp_base_contract_schemes.0668.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = chaplain
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_learning_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0668.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Intrigue
	option = {
		name = laamp_base_contract_schemes.0668.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.intrigue
				NOT = { has_character_flag = laamp_base_0031_contract_used_intrigue }
			}
		}
		show_as_unavailable = { always = yes }
		skill = intrigue

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = intrigue }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Learning
	option = {
		name = laamp_base_contract_schemes.0668.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.learning
				NOT = { has_character_flag = laamp_base_0031_contract_used_learning }
			}
		}
		show_as_unavailable = { always = yes }
		skill = learning

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = learning }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = learning
				always = yes
			}
		}
	}
}

#	Diplomacy + intrigue + prowess
laamp_base_contract_schemes.0669 = {
	type = character_event
	title = laamp_base_contract_schemes.0669.t
	desc = laamp_base_contract_schemes.0669.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = spymaster
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_intrigue_prowess_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0669.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Intrigue
	option = {
		name = laamp_base_contract_schemes.0669.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.intrigue
				NOT = { has_character_flag = laamp_base_0031_contract_used_intrigue }
			}
		}
		show_as_unavailable = { always = yes }
		skill = intrigue

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = intrigue }

		laamp_base_contract_schemes_0664_threatening_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Prowess
	option = {
		name = laamp_base_contract_schemes.0669.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.prowess
				NOT = { has_character_flag = laamp_base_0031_contract_used_prowess }
			}
		}
		show_as_unavailable = { always = yes }
		skill = prowess

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = prowess }

		laamp_base_contract_schemes_0664_peaceful_stress_effect = yes
		ai_chance = {
			base = 1
			modifier = {
				add = prowess
				always = yes
			}
		}
	}
}

#	Diplomacy + learning + prowess
laamp_base_contract_schemes.0670 = {
	type = character_event
	title = laamp_base_contract_schemes.0670.t
	desc = laamp_base_contract_schemes.0670.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = chaplain
	}
	override_background = { reference = wilderness }

	trigger = {
		location = { has_province_modifier = laamp_base_0031_contract_scheme_challenge_diplomacy_learning_prowess_modifier }
	}

	immediate = {
		# Set up our difficulty.
		laamp_base_contract_schemes_0661_setup_difficulties_effect = yes
		# Plus grab our location, in case we move.
		location = { save_scope_as = location }
	}

	# Diplomacy
	option = {
		name = laamp_base_contract_schemes.0670.a
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.diplomacy
				NOT = { has_character_flag = laamp_base_0031_contract_used_diplomacy }
			}
		}
		show_as_unavailable = { always = yes }
		skill = diplomacy

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Learning
	option = {
		name = laamp_base_contract_schemes.0670.b
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.learning
				NOT = { has_character_flag = laamp_base_0031_contract_used_learning }
			}
		}
		show_as_unavailable = { always = yes }
		skill = learning

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = learning }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = learning
				always = yes
			}
		}
	}
	
	# Prowess
	option = {
		name = laamp_base_contract_schemes.0670.c
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.0661.tt.skill_used.prowess
				NOT = { has_character_flag = laamp_base_0031_contract_used_prowess }
			}
		}
		show_as_unavailable = { always = yes }
		skill = prowess

		laamp_base_contract_schemes_0661_duel_generic_effect = { SKILL = prowess }

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = prowess
				always = yes
			}
		}
	}
}

#	Threshold met, d'ye wanna go for the exceptional or not?
laamp_base_contract_schemes.0671 = {
	type = character_event
	title = laamp_base_contract_schemes.0671.t
	desc = laamp_base_contract_schemes.0671.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:target
		animation = admiration
	}
	override_background = { reference = wilderness }

	immediate = {
		current_travel_plan = { pause_travel_plan = yes }
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_0031 }
			save_scope_as = task_contract
			save_scope_value_as = {
				name = task_contract_tier
				value = task_contract_tier
			}
			task_contract_employer = { save_scope_as = employer }
		}
	}

	# Take the success as-is.
	option = {
		name = laamp_base_contract_schemes.0671.a
		
		custom_tooltip = laamp_base_contract_schemes.0671.a.tt
		scope:task_contract = { complete_task_contract = success_standard }
		hidden_effect = {
			return_home = yes
		}
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_0031_success_employer_modifier
				years = 10
			}
			add_prestige = medium_prestige_gain
		}

		# No stress, straight-choice event.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -1 }
		}
	}
	
	# Go for the exceptional.
	option = {
		name = laamp_base_contract_schemes.0671.b
		trigger = {
			OR = {
				is_ai = no
				has_trait = arrogant
			}
		}
		
		custom_tooltip = laamp_base_contract_schemes.0671.b.tt
		current_travel_plan = { resume_travel_plan = yes }

		# No stress, straight-choice event.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
}

##################################################
# Confidence trickster (on-going)
# by Ewan Cowhig Croft
# 0781 - 0900
##################################################

scripted_effect laamp_base_contract_schemes_0781_pay_gold_effect = {
	scope:target = {
		pay_short_term_gold = {
			target = root
			gold = medium_gold_value
		}
		add_opinion = {
			target = root
			modifier = suspicious_opinion
			opinion = -10
		}
	}
	laamp_rewards_apply_criminal_xp_effect = {
		TRACK = thief
		XP_MAX = gallowsbait_xp_medium_gain
		XP_MIN = gallowsbait_xp_medium_gain
	}
}

scripted_effect laamp_base_contract_schemes_0781_fail_duel_effect = {
	reverse_add_opinion = {
		target = scope:target
		modifier = suspicious_opinion
		opinion = -25
	}
	laamp_rewards_apply_criminal_xp_effect = {
		TRACK = thief
		XP_MAX = gallowsbait_xp_minor_gain
		XP_MIN = gallowsbait_xp_minor_gain
	}
}

#	Also rob the place.
laamp_base_contract_schemes.0781 = {
	type = character_event
	title = laamp_base_contract_schemes.0781.t
	desc = laamp_base_contract_schemes.0781.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_greedy
	}
	right_portrait = {
		character = scope:target
		animation = steward
	}
	override_background = { reference = throne_room_scope }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0781 }
		}
	}

	immediate = {
		scope:scheme = {
			# Set our per-scheme cooldown.
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0781
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Plus our difficulties.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
		scope:target = { save_scope_as = background_throne_room_scope }
		# If we've got a stooge, collect 'em.
		random_court_position_holder = {
			limit = {
				has_court_position = stooge_camp_officer
				is_available_allow_travelling = yes
			}
			save_scope_as = stooge
		}
	}

	# Diplo duel.
	option = {
		name = laamp_base_contract_schemes.0781.a
		
		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# Victory.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0781.a.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0781_pay_gold_effect = yes
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0781.a.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0781_fail_duel_effect = yes
				}
			}
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 1 }
		}
	}
	
	# Intrigue duel.
	option = {
		name = laamp_base_contract_schemes.0781.b
		trigger = {
			NOT = { exists = scope:stooge }
		}

		duel = {
			skill = intrigue
			value = scope:duel_diff
			# Victory.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.b.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0781.b.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0781_pay_gold_effect = yes
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.b.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0781.b.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0781_fail_duel_effect = yes
				}
			}
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -1 }
		}
	}
	
	# Frame your stooge.
	option = {
		name = laamp_base_contract_schemes.0781.c
		trigger = { exists = scope:stooge }
		reason = have_stooge

		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# Victory.
			70 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.c.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0781.c.tt.success
					left_icon = scope:target
					scope:target = {
						pay_short_term_gold = {
							target = root
							gold = medium_gold_value
						}
						add_opinion = {
							target = scope:stooge
							modifier = suspicious_opinion
							opinion = -50
						}
					}
					reverse_add_opinion = {
						target = scope:stooge
						modifier = angry_opinion
						opinion = -20
					}
				}
			}
			# Defeat.
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.c.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0781.c.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0781_fail_duel_effect = yes
					reverse_add_opinion = {
						target = scope:stooge
						modifier = angry_opinion
						opinion = -20
					}
				}
			}
		}

		stress_impact = {
			sadistic = miniscule_stress_impact_loss
			callous = minor_stress_impact_loss
			compassionate = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_compassion = -1 }
		}
	}
	
	# Prowess duel.
	option = {
		name = laamp_base_contract_schemes.0781.d
		
		duel = {
			skill = prowess
			value = scope:duel_diff
			# Victory.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.d.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0781.d.tt.success
					left_icon = scope:target
					laamp_base_contract_schemes_0781_pay_gold_effect = yes
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0781.d.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0781.d.tt.failure
					left_icon = scope:target
					laamp_base_contract_schemes_0781_fail_duel_effect = yes
				}
			}
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 1 }
		}
	}
	
	# Keep it honest.
	option = {
		name = laamp_base_contract_schemes.0781.e
		
		# Slight stress reduction as default.
		stress_impact = {
			base = medium_stress_loss
			deceitful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0791_armoury_artefact_group_trigger = {
	OR = {
		artifact_slot_type = helmet
		artifact_slot_type = armor
		artifact_slot_type = primary_armament
	}
}

scripted_trigger laamp_base_contract_schemes_0791_luxuries_artefact_group_trigger = {
	OR = {
		artifact_slot_type = regalia
		artifact_slot_type = pedestal
		AND = {
			artifact_slot_type = miscellaneous
			NOR = {
				has_artifact_feature_group = animal_trinket_type
				has_artifact_feature_group = bird_feather_type
				# Rule out tourney tokens.
				has_artifact_feature_group = generic_material_cloth
			}
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0791_trinkets_artefact_group_trigger = {
	OR = {
		artifact_slot_type = book
		artifact_slot_type = pedestal
		AND = {
			artifact_slot_type = miscellaneous
			NOR = {
				has_artifact_feature_group = animal_trinket_type
				has_artifact_feature_group = bird_feather_type
				# Rule out tourney tokens.
				has_artifact_feature_group = generic_material_cloth
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_0791_fail_duel_effect = {
	reverse_add_opinion = {
		target = scope:target
		modifier = suspicious_opinion
		opinion = -25
	}
	laamp_rewards_apply_criminal_xp_effect = {
		TRACK = $TRACK$
		XP_MAX = gallowsbait_xp_minor_gain
		XP_MIN = gallowsbait_xp_minor_gain
	}
}

scripted_effect laamp_base_contract_schemes_0791_select_artefact_to_steal_effect = {
	scope:target = {
		ordered_character_artifact = {
			limit = {
				is_equipped = no
				laamp_base_contract_schemes_0791_$STEALABLE_GROUP$_artefact_group_trigger = yes
			}
			order_by = {
				value = artifact_rarity
				# Boost anything we've got a claim on.
				save_temporary_scope_as = artefact_temp
				if = {
					limit = {
						root = { has_artifact_claim = scope:artefact_temp }
					}
					add = 100
				}
			}
			save_scope_as = $ARTEFACT_SCOPE$
		}
	}
}

#	Officers help out.
laamp_base_contract_schemes.0791 = {
	type = character_event
	title = laamp_base_contract_schemes.0791.t
	desc = laamp_base_contract_schemes.0791.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:target
		animation = admiration
	}
	override_background = { reference = feast_event }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0791 }
		}
		# Event-specific checks.
		NOT = {
			scope:scheme = { has_scheme_modifier = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
		}
		OR = {
			court_position:second_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:quartermaster_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:armorer_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:chief_forager_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:master_thief_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:head_groom_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:huntperson_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:witness_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:camp_cook_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:master_bard_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:stooge_camp_officer ?= { is_available_allow_travelling = yes }
			court_position:master_of_spoils_camp_officer ?= { is_available_allow_travelling = yes }
		}
	}

	immediate = {
		# Set our per-scheme cooldown.
		scope:scheme = {
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0791
				years = @event_in_same_scheme_cooldown_years_value
			}
		}
		# Process our available court positions.
		## First, we gather them.
		court_position:second_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = second
				add_to_list = prospective_positions_list
			}
		}
		court_position:quartermaster_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = quartermaster
				add_to_list = prospective_positions_list
			}
		}
		court_position:armorer_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = armourer
				add_to_list = prospective_positions_list
				# Alright, let's try to steal an artefact.
				laamp_base_contract_schemes_0791_select_artefact_to_steal_effect = {
					STEALABLE_GROUP = armoury
					ARTEFACT_SCOPE = armourer_artefact
				}
			}
		}
		court_position:chief_forager_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = chief_forager
				add_to_list = prospective_positions_list
			}
		}
		court_position:master_thief_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = master_thief
				add_to_list = prospective_positions_list
				laamp_base_contract_schemes_0791_select_artefact_to_steal_effect = {
					STEALABLE_GROUP = luxuries
					ARTEFACT_SCOPE = master_thief_artefact
				}
			}
		}
		court_position:head_groom_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = head_groom
				add_to_list = prospective_positions_list
			}
		}
		court_position:huntperson_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = huntperson
				add_to_list = prospective_positions_list
			}
		}
		court_position:witness_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = witness
				add_to_list = prospective_positions_list
			}
		}
		court_position:camp_cook_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = camp_cook
				add_to_list = prospective_positions_list
			}
		}
		court_position:master_bard_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = master_bard
				add_to_list = prospective_positions_list
				laamp_base_contract_schemes_0791_select_artefact_to_steal_effect = {
					STEALABLE_GROUP = trinkets
					ARTEFACT_SCOPE = master_bard_artefact
				}
			}
		}
		court_position:stooge_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = stooge
				add_to_list = prospective_positions_list
			}
		}
		court_position:master_of_spoils_camp_officer ?= {
			if = {
				limit = { is_available_allow_travelling = yes }
				save_scope_as = master_of_spoils
				add_to_list = prospective_positions_list
				laamp_base_contract_schemes_0791_select_artefact_to_steal_effect = {
					STEALABLE_GROUP = luxuries
					ARTEFACT_SCOPE = master_of_spoils_artefact
				}
			}
		}
		## Ok, now that we've got them, go over the list and check who's best at their job.
		ordered_in_list = {
			list = prospective_positions_list
			order_by = {
				if = {
					limit = { has_court_position = second_camp_officer }
					add = "aptitude(second_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = quartermaster_camp_officer }
					add = "aptitude(quartermaster_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = armorer_camp_officer }
					add = "aptitude(armorer_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = chief_forager_camp_officer }
					add = "aptitude(chief_forager_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = master_thief_camp_officer }
					add = "aptitude(master_thief_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = head_groom_camp_officer }
					add = "aptitude(head_groom_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = huntperson_camp_officer }
					add = "aptitude(huntperson_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = witness_camp_officer }
					add = "aptitude(witness_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = camp_cook_camp_officer }
					add = "aptitude(camp_cook_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = master_bard_camp_officer }
					add = "aptitude(master_bard_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = stooge_camp_officer }
					add = "aptitude(stooge_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = master_of_spoils_camp_officer }
					add = "aptitude(master_of_spoils_camp_officer)"
				}
			}
			max = 3
			check_range_bounds = no
			if = {
				limit = {
					NOT = { is_in_list = best_positions_list }
				}
				add_to_list = best_positions_list
			}
		}
		# And our duel diffs.
		scope:scheme = { laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes }
	}

	# Second: pull an efficient double-act.
	option = {
		name = laamp_base_contract_schemes.0791.a
		trigger = {
			scope:second ?= { is_in_list = best_positions_list }
		}
		reason = have_second

		scope:second = {
			duel = {
				skills = { diplomacy martial stewardship intrigue learning prowess }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:second
							right_icon = scope:target
							scope:target = {
								pay_short_term_gold = {
									target = root
									gold = medium_gold_value
								}
								add_opinion = {
									target = root
									modifier = suspicious_opinion
									opinion = -10
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = trickster
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:second
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = trickster }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = trickster }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:second }
		}
	}
	
	# Quartermaster: raid their storage.
	option = {
		name = laamp_base_contract_schemes.0791.b
		trigger = {
			scope:quartermaster ?= { is_in_list = best_positions_list }
		}
		reason = have_quartermaster

		scope:quartermaster = {
			duel = {
				skill = stewardship
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:quartermaster
							right_icon = scope:target
							scope:target = {
								pay_short_term_gold = {
									target = root
									gold = minor_gold_value
								}
							}
							domicile = {
								change_provisions = {
									value = scope:provisions_gain
									multiply = 0.5
									ceiling = yes
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = thief
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					add_opinion = {
						target = scope:target
						modifier = suspicious_opinion
						opinion = -10
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:quartermaster
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:quartermaster }
		}
	}
	
	# Armourer: raid their armoury.
	option = {
		name = laamp_base_contract_schemes.0791.c
		trigger = {
			scope:armourer ?= { is_in_list = best_positions_list }
		}
		reason = have_armourer

		scope:armourer = {
			duel = {
				skills = { stewardship learning }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:armourer
							right_icon = scope:target
							if = {
								limit = { exists = scope:armourer_artefact }
								steal_artifact_in_event_effect = {
									THIEF = root
									VICTIM = scope:target
									ARTIFACT = scope:armourer_artefact
								}
							}
							else = {
								scope:target = {
									pay_short_term_gold = {
										target = root
										gold = medium_gold_value
									}
									add_opinion = {
										target = root
										modifier = suspicious_opinion
										opinion = -10
									}
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = thief
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:armourer
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:armourer }
		}
	}
	
	# Forager: raid their gardens.
	option = {
		name = laamp_base_contract_schemes.0791.d
		trigger = {
			scope:chief_forager ?= { is_in_list = best_positions_list }
		}
		reason = have_chief_forager

		scope:chief_forager = {
			duel = {
				skills = { learning prowess }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:chief_forager
							right_icon = scope:target
							domicile = { change_provisions = scope:provisions_gain }
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = poacher
								XP_MAX = gallowsbait_xp_minor_gain
								XP_MIN = gallowsbait_xp_minor_gain
							}
						}
					}
					add_opinion = {
						target = scope:target
						modifier = suspicious_opinion
						opinion = -10
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:chief_forager
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = poacher }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = poacher }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:chief_forager }
		}
	}
	
	# Master Thief: raid their treasury.
	option = {
		name = laamp_base_contract_schemes.0791.e
		trigger = {
			scope:master_thief ?= { is_in_list = best_positions_list }
		}
		reason = have_master_thief

		scope:master_thief = {
			duel = {
				skills = { intrigue prowess }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:master_thief
							right_icon = scope:target
							if = {
								limit = { exists = scope:master_thief_artefact }
								steal_artifact_in_event_effect = {
									THIEF = root
									VICTIM = scope:target
									ARTIFACT = scope:master_thief_artefact
								}
							}
							else = {
								scope:target = {
									pay_short_term_gold = {
										target = root
										gold = major_gold_value
									}
									add_opinion = {
										target = root
										modifier = suspicious_opinion
										opinion = -10
									}
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = thief
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:master_thief
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:master_thief }
		}
	}
	
	# Groom: steal horses.
	option = {
		name = laamp_base_contract_schemes.0791.f
		trigger = {
			scope:head_groom ?= { is_in_list = best_positions_list }
		}
		reason = have_head_groom

		scope:head_groom = {
			duel = {
				skills = { learning stewardship }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:head_groom
							right_icon = scope:target
							scope:target = {
								pay_short_term_gold = {
									target = root
									gold = minor_gold_value
								}
								add_opinion = {
									target = root
									modifier = suspicious_opinion
									opinion = -10
								}
							}
							add_character_modifier = {
								modifier = laamp_base_contract_schemes_0791_plentiful_horses_modifier
								years = 10
							}
						}
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:head_groom
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:head_groom }
		}
	}
	
	# Huntsman: raid their lodges.
	option = {
		name = laamp_base_contract_schemes.0791.g
		trigger = {
			scope:huntperson ?= { is_in_list = best_positions_list }
		}
		reason = have_huntperson

		scope:huntperson = {
			duel = {
				skills = { prowess learning }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:huntperson
							right_icon = scope:target
							domicile = { change_provisions = scope:provisions_gain }
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = poacher
								XP_MAX = gallowsbait_xp_minor_gain
								XP_MIN = gallowsbait_xp_minor_gain
							}
						}
					}
					add_opinion = {
						target = scope:target
						modifier = suspicious_opinion
						opinion = -10
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:huntperson
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = poacher }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = poacher }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:huntperson }
		}
	}
	
	# Witness: spread your good name even whilst you rob them blind.
	option = {
		name = laamp_base_contract_schemes.0791.h
		trigger = {
			scope:witness ?= { is_in_list = best_positions_list }
		}
		reason = have_witness

		scope:witness = {
			duel = {
				skill = diplomacy
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:witness
							right_icon = scope:target
							scope:target = {
								pay_short_term_gold = {
									target = root
									gold = minor_gold_value
								}
							}
							add_prestige = medium_prestige_gain
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = trickster
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:witness
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = trickster }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = trickster }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:witness }
		}
	}
	
	# Cook: raid their larder.
	option = {
		name = laamp_base_contract_schemes.0791.i
		trigger = {
			scope:camp_cook ?= { is_in_list = best_positions_list }
		}
		reason = have_camp_cook

		scope:camp_cook = {
			duel = {
				skills = { intrigue }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:camp_cook
							right_icon = scope:target
							domicile = { change_provisions = scope:provisions_gain }
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = poacher
								XP_MAX = gallowsbait_xp_minor_gain
								XP_MIN = gallowsbait_xp_minor_gain
							}
						}
					}
					add_opinion = {
						target = scope:target
						modifier = suspicious_opinion
						opinion = -10
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:camp_cook
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:camp_cook }
		}
	}
	
	# Bard: keep them busy.
	option = {
		name = laamp_base_contract_schemes.0791.j
		trigger = {
			scope:master_bard ?= { is_in_list = best_positions_list }
		}
		reason = have_master_bard

		scope:master_bard = {
			duel = {
				skills = { diplomacy learning }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:master_bard
							right_icon = scope:target
							if = {
								limit = { exists = scope:master_bard_artefact }
								steal_artifact_in_event_effect = {
									THIEF = root
									VICTIM = scope:target
									ARTIFACT = scope:master_bard_artefact
								}
							}
							else = {
								scope:target = {
									pay_short_term_gold = {
										target = root
										gold = minor_gold_value
									}
									add_opinion = {
										target = root
										modifier = suspicious_opinion
										opinion = -10
									}
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = trickster
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:master_bard
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = trickster }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = trickster }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:master_bard }
		}
	}
	
	# Stooge: frame them.
	option = {
		name = laamp_base_contract_schemes.0791.k
		trigger = {
			scope:stooge ?= { is_in_list = best_positions_list }
		}
		reason = have_stooge

		duel = {
			skill = intrigue
			target = scope:stooge
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0791.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0791.tt.success
					left_icon = scope:stooge
					right_icon = scope:target
					scope:target = {
						pay_short_term_gold = {
							target = root
							gold = minor_gold_value
						}
						add_opinion = {
							target = scope:stooge
							modifier = suspicious_opinion
							opinion = -50
						}
					}
					reverse_add_opinion = {
						target = scope:stooge
						modifier = angry_opinion
						opinion = -20
					}
				}
				scope:stooge = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
			}
			# Failure.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0791.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0791.tt.failure
					left_icon = scope:stooge
					right_icon = scope:target
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
					scope:scheme = {
						add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
					}
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:stooge }
		}
	}
	
	# Master of Spoils: loot everything that's not nailed down.
	option = {
		name = laamp_base_contract_schemes.0791.l
		trigger = {
			scope:master_of_spoils ?= { is_in_list = best_positions_list }
		}
		reason = have_master_of_spoils

		scope:master_of_spoils = {
			duel = {
				skills = { stewardship intrigue martial }
				value = scope:duel_diff
				# Success!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0791.tt.success
							left_icon = scope:master_of_spoils
							right_icon = scope:target
							if = {
								limit = { exists = scope:master_of_spoils_artefact }
								steal_artifact_in_event_effect = {
									THIEF = root
									VICTIM = scope:target
									ARTIFACT = scope:master_of_spoils_artefact
								}
							}
							else = {
								scope:target = {
									pay_short_term_gold = {
										target = root
										gold = medium_gold_value
									}
									add_opinion = {
										target = root
										modifier = suspicious_opinion
										opinion = -10
									}
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = thief
								XP_MAX = gallowsbait_xp_medium_gain
								XP_MIN = gallowsbait_xp_medium_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0791.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0791.tt.failure
							left_icon = scope:master_of_spoils
							right_icon = scope:target
							laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
							scope:scheme = {
								add_scheme_modifier = { type = laamp_base_contract_schemes_0791_suspicious_officers_modifier }
							}
						}
					}
					laamp_base_contract_schemes_0791_fail_duel_effect = { TRACK = thief }
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:master_of_spoils }
		}
	}
	
	# Too risky, better not.
	option = {
		name = laamp_base_contract_schemes.0791.m
		
		# Mild stress loss for most.
		stress_impact = {
			base = medium_stress_loss
			lustful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -1 }
		}
	}
}

#	Try harder to get into their good graces.
laamp_base_contract_schemes.0801 = {
	type = character_event
	title = laamp_base_contract_schemes.0801.t
	desc = laamp_base_contract_schemes.0801.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:target
		animation = happiness
	}
	override_background = { reference = relaxing_room_scope }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0801 }
		}
		# Event-specific checks.
		scope:scheme = {
			NOT = { has_scheme_modifier = laamp_base_contract_schemes_0801_target_good_graces_modifier }
		}
	}

	immediate = {
		scope:scheme = {
			# Set our per-scheme cooldown.
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0801
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Plus our difficulties.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
		scope:target = { save_scope_as = background_relaxing_room_scope }
		# If we've got a master bard, collect 'em.
		random_court_position_holder = {
			limit = { has_court_position = master_bard_camp_officer }
			save_scope_as = bard
		}
	}

	# Difficult diplo duel.
	option = {
		name = laamp_base_contract_schemes.0801.a
		
		duel = {
			skill = diplomacy
			value = scope:duel_diff
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0801.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.0801.a.tt.success
					left_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = {
							type = laamp_base_contract_schemes_0801_target_good_graces_modifier
							days = 1825
						}
					}
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.0801.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.0801.a.tt.failure
					left_icon = scope:target
					scope:scheme = {
						add_scheme_modifier = {
							type = laamp_base_contract_schemes_0801_target_irritated_modifier
							days = 1825
						}
					}
				}
			}
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
		}
	}
	
	# Spend your own prestige.
	option = {
		name = laamp_base_contract_schemes.0801.b
		
		add_prestige = medium_prestige_loss
		scope:scheme = {
			add_scheme_modifier = {
				type = laamp_base_contract_schemes_0801_target_good_graces_modifier
				days = 1825
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
	
	# Tag your master bard in.
	option = {
		name = laamp_base_contract_schemes.0801.c
		trigger = { exists = scope:bard }
		reason = have_master_bard

		scope:bard = {
			duel = {
				skill = diplomacy
				value = scope:duel_diff
				# Victory!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0801.c.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0801.c.tt.success
							left_icon = scope:target
							scope:scheme = {
								add_scheme_modifier = {
									type = laamp_base_contract_schemes_0801_target_good_graces_modifier
									days = 1825
								}
							}
						}
					}
				}
				# Defeat.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0801.c.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0801.c.tt.failure
							left_icon = scope:target
							scope:scheme = {
								add_scheme_modifier = {
									type = laamp_base_contract_schemes_0801_target_irritated_modifier
									days = 1825
								}
							}
						}
					}
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:bard }
		}
	}
	
	# Don't do anything.
	option = {
		name = laamp_base_contract_schemes.0801.d
		
		# Marginal stress loss.
		stress_impact = {
			base = medium_stress_loss
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -1 }
		}
	}
}

scripted_trigger laamp_base_contract_schemes_0811_agent_with_side_hustle_trigger = {
	NOR = {
		has_trait = honest
		has_trait = just
	}
	OR = {
		has_trait = greedy
		has_trait = diligent
		has_trait = impatient
		has_trait = arrogant
		has_trait = deceitful
		has_trait = brave
		has_trait = gregarious
		has_trait = ambitious
		has_trait = arbitrary
	}
}

#	Agents running side-games.
laamp_base_contract_schemes.0811 = {
	type = character_event
	title = laamp_base_contract_schemes.0811.t
	desc = laamp_base_contract_schemes.0811.desc
	theme = diplomacy
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:agent
		animation = steward
	}
	lower_center_portrait = scope:target
	override_background = { reference = corridor_night }

	# So that you don't see the same events between schemes in _too_ rapid a succession.
	cooldown = { years = 1 }

	trigger = {
		# DLC check.
		has_ep3_dlc_trigger = yes
		# Standard checks.
		NOT = {
			scope:scheme = { has_variable = had_event_laamp_base_contract_schemes_0801 }
		}
		# Event-specific checks.
		scope:scheme = {
			any_scheme_agent_character = { laamp_base_contract_schemes_0811_agent_with_side_hustle_trigger = yes }
		}
	}

	immediate = {
		scope:scheme = {
			# Set our per-scheme cooldown.
			set_variable = {
				name = had_event_laamp_base_contract_schemes_0801
				years = @event_in_same_scheme_cooldown_years_value
			}
			# Plus our difficulties.
			laamp_base_contract_schemes_check_contract_difficulty_and_rewards_effect = yes
		}
		# Grab a suitable agent.
		scope:scheme = {
			ordered_scheme_agent_character = {
				limit = { laamp_base_contract_schemes_0811_agent_with_side_hustle_trigger = yes }
				order_by = {
					value = intrigue
					# Weight up certain traits heavily.
					## Greedy.
					if = {
						limit = { has_trait = greedy }
						add = 10
					}
					## Deceitful.
					if = {
						limit = { has_trait = deceitful }
						add = 10
					}
					## Arbitrary.
					if = {
						limit = { has_trait = arbitrary }
						add = 10
					}
				}
				save_scope_as = agent
			}
		}
	}

	# Encourage this — if you get a cut.
	option = {
		name = laamp_base_contract_schemes.0811.a
		
		scope:agent = {
			duel = {
				skill = intrigue
				value = scope:duel_diff
				# Victory!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0811.a.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0811.a.tt.success
							left_icon = scope:agent
							right_icon = scope:target
							save_scope_value_as = {
								name = halved_gold
								value = {
									value = scope:target.medium_gold_value
									multiply = 0.5
									ceiling = yes
								}
							}
							scope:target = {
								pay_short_term_gold = {
									target = root
									gold = scope:halved_gold
								}
								pay_short_term_gold = {
									target = scope:agent
									gold = scope:halved_gold
								}
							}
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = trickster
								XP_MAX = gallowsbait_xp_minor_gain
								XP_MIN = gallowsbait_xp_minor_gain
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
					scope:target = {
						add_opinion = {
							target = root
							modifier = suspicious_opinion
							opinion = -10
						}
						add_opinion = {
							target = scope:agent
							modifier = suspicious_opinion
							opinion = -10
						}
					}
				}
				# Defeat.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0811.a.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0811.a.tt.failure
							left_icon = scope:agent
							right_icon = scope:target
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = trickster
								XP_MAX = gallowsbait_xp_minor_gain
								XP_MIN = gallowsbait_xp_minor_gain
							}
							scope:target = {
								add_opinion = {
									target = root
									modifier = suspicious_opinion
									opinion = -30
								}
								add_opinion = {
									target = scope:agent
									modifier = suspicious_opinion
									opinion = -30
								}
							}
						}
					}
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}

		stress_impact = {
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_greed = 2 }
		}
	}
	
	# Carry on, carry on.
	option = {
		name = laamp_base_contract_schemes.0811.b
		
		reverse_add_opinion = {
			target = scope:agent
			modifier = grateful_opinion
			opinion = 30
		}
		add_favour_hook_if_possible_simple_effect = { TARGET = scope:agent }
		scope:agent = {
			duel = {
				skill = intrigue
				value = scope:duel_diff
				# Victory!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0811.c.tt.success
					root = {
						send_interface_toast = {
							type = event_generic_good
							title = laamp_base_contract_schemes.0811.c.tt.success
							left_icon = scope:agent
							right_icon = scope:target
							scope:target = {
								pay_short_term_gold = {
									target = scope:agent
									gold = medium_gold_value
								}
								add_opinion = {
									target = scope:agent
									modifier = suspicious_opinion
									opinion = -10
								}
							}
							scope:agent = {
								laamp_rewards_apply_criminal_xp_effect = {
									TRACK = trickster
									XP_MAX = gallowsbait_xp_minor_gain
									XP_MIN = gallowsbait_xp_minor_gain
								}
							}
						}
					}
				}
				# Defeat.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					min = 5
					desc = laamp_base_contract_schemes.0811.c.tt.failure
					root = {
						send_interface_toast = {
							type = event_generic_bad
							title = laamp_base_contract_schemes.0811.c.tt.failure
							left_icon = scope:agent
							right_icon = scope:target
							scope:agent = {
								laamp_rewards_apply_criminal_xp_effect = {
									TRACK = trickster
									XP_MAX = gallowsbait_xp_minor_gain
									XP_MIN = gallowsbait_xp_minor_gain
								}
								reverse_add_opinion = {
									target = scope:target
									modifier = suspicious_opinion
									opinion = -30
								}
							}
						}
					}
				}
			}
		}

		stress_impact = {
			generous = miniscule_stress_impact_loss
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			opinion_modifier = { opinion_target = scope:agent }
		}
	}
	
	# Stop that you fool.
	option = {
		name = laamp_base_contract_schemes.0811.c
		
		reverse_add_opinion = {
			target = scope:agent
			modifier = annoyed_opinion
			opinion = -30
		}

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 1 }
		}
	}
}


 








##################################################
# SETUP — MARTIAL

##################################################
# Hunt criminals (setup)
# by Ewan Cowhig Croft
# 1001 - 1010
##################################################

#	Intro event.
laamp_base_contract_schemes.1001 = {
	type = character_event
	title = laamp_base_contract_schemes.1001.t
	desc = laamp_base_contract_schemes.1001.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = throne_room }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.1001.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_scout
			add_agent_slot = agent_ambusher
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_planner
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.1001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_scout
			add_agent_slot = agent_outrider
			# Speed.
			add_agent_slot = agent_tracker
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.1001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scout
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_tracker
			add_agent_slot = agent_planner
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.1002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1002.t
	desc = laamp_base_contract_schemes.1002.desc
	theme = martial
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = hunting_knife_start
	}
	override_background = { reference = dungeon }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer.capital_county = {
			# If we have less than full control in the capital, then boost that.
			if = {
				limit = { county_control < full_county_control }
				change_county_control = major_county_control_gain
			}
			# Else try to boost a neighbouring county.
			else_if = {
				limit = {
					any_neighboring_county = { laamp_base_1001_valid_neighbouring_county_trigger = yes }
				}
				random_neighboring_county = {
					limit = { laamp_base_1001_valid_neighbouring_county_trigger = yes }
					change_county_control = major_county_control_gain
				}
			}
			# Else we give a nice modifier.
			else_if = {
				limit = {
					scope:employer = { contract_employer_can_apply_county_modifier_trigger = yes }
				}
				add_county_modifier = {
					modifier = laamp_base_1001_success_employer_modifier
					years = 20
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.1003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1003.t
	desc = laamp_base_contract_schemes.1003.desc
	theme = martial
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer.capital_county = { change_county_control = major_county_control_loss }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_1004_organise_travel_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		on_arrival_event = laamp_base_contract_schemes.1301
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.1005
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.1004 = {
	type = character_event
	title = laamp_base_contract_schemes.1004.t
	desc = laamp_base_contract_schemes.1004.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
		outfit_tags = { military_outfit }
	}
	lower_center_portrait = scope:recidivist
	override_background = { reference = bedchamber }

	immediate = {
		# Grab three counties within our employer's de jure kingdom.
		scope:employer.capital_county = {
			# Which'll be their capital as our start, every time.
			save_scope_as = destination_1
			# Then we want to put all the other duchies in a list.
			kingdom = {
				every_in_de_jure_hierarchy = {
					continue = { tier >= tier_duchy }
					limit = { tier = tier_duchy }
					add_to_list = possible_duchies_list
				}
			}
			# And sort through the list at random to pick possible destinations.
			## Our first.
			random_in_list = {
				list = possible_duchies_list
				weight = {
					# Weight up for richness.
					modifier = {
						add = title_capital_county.development_level
						always = yes
					}
					# And a lack of control.
					modifier = {
						add = {
							value = 100
							subtract = title_capital_county.county_control
							multiply = 2
						}
						always = yes
					}
				}
				# Try to get somewhere that isn't immediately next to our first destination.
				limit = {
					NOR = {
						this = scope:destination_1.duchy
						any_title_to_title_neighboring_and_across_water_duchy = { this = scope:destination_1.duchy }
					}
				}
				alternative_limit = {
					NOT = { this = scope:destination_1.duchy }
				}
				title_capital_county = { save_scope_as = destination_2 }
			}
			## Our second.
			random_in_list = {
				list = possible_duchies_list
				weight = {
					# Weight up for richness.
					modifier = {
						add = title_capital_county.development_level
						always = yes
					}
					# And a lack of control.
					modifier = {
						add = {
							value = 100
							subtract = title_capital_county.county_control
							multiply = 2
						}
						always = yes
					}
				}
				# Try to get somewhere that isn't immediately next to our first destinations.
				limit = {
					NOR = {
						this = scope:destination_1.duchy
						this = scope:destination_2.duchy
						any_title_to_title_neighboring_and_across_water_duchy = {
							OR = {
								this = scope:destination_1.duchy
								this = scope:destination_2.duchy
							}
						}
					}
				}
				alternative_limit = {
					NOR = {
						this = scope:destination_1.duchy
						this = scope:destination_2.duchy
					}
				}
				title_capital_county = { save_scope_as = destination_3 }
			}
		}
		# Now, find us a suitable criminal.
		## Trying to get someone from the pool.
		if = {
			limit = {
				# We only do this for the player, no sense calculating all this stuff for an AI.
				is_ai = no
			}
			# First we empty a de jure empire's worth of pool characters into a list.
			## Which means assembling the relevant pools.
			scope:employer.capital_county.empire = {
				every_in_de_jure_hierarchy = {
					continue = { tier >= tier_duchy }
					limit = { tier = tier_duchy }
					add_to_list = pool_duchies_list
				}
			}
			## And compiling the list.
			every_in_list = {
				list = pool_duchies_list
				title_capital_county.title_province = { save_scope_as = province_temp }
				every_pool_character = {
					province = scope:province_temp
					limit = {
						is_available_healthy_ai_adult = yes
						can_start_single_combat_trigger = yes
						NOR = {
							has_trait = honest
							has_trait = compassionate
							has_trait = craven
						}
						OR = {
							has_trait = gallowsbait
							calc_true_if = {
								amount >= 2
								# Common traits.
								has_trait = arrogant
								has_trait = deceitful
								has_trait = brave
								has_trait = paranoid
								has_trait = callous
								has_trait = sadistic
								has_trait = vengeful
								has_trait = eccentric
								# Esoteric stuff.
								has_trait = schemer
								has_trait = torturer
								has_trait = excommunicated
								has_trait = berserker
								has_trait = kinslayer_1
								has_trait = kinslayer_2
								has_trait = kinslayer_3
								has_trait = cannibal
								has_trait = murderer
								has_trait = viking
								has_trait = disloyal
							}
						}
					}
					add_to_list = pool_characters_list
				}
			}
			# Then we sort through that list to find the worst dude.
			ordered_in_list = {
				list = pool_characters_list
				order_by = {
					# Skills.
					add = intrigue
					add = martial
					add = prowess
					# Personality values.
					add = {
						value = ai_honor
						multiply = -0.5
					}
					add = {
						value = ai_vengefulness
						multiply = 0.25
					}
					# Plus up-weight certain things drastically.
					## Traits.
					if = {
						limit = { has_trait = paranoid }
						add = 20
					}
					if = {
						limit = { has_trait = sadistic }
						add = 20
					}
					if = {
						limit = { has_trait = vengeful }
						add = 20
					}
					if = {
						limit = { has_trait = torturer }
						add = 20
					}
					if = {
						limit = { has_trait = kinslayer_1 }
						add = 20
					}
					if = {
						limit = { has_trait = kinslayer_2 }
						add = 20
					}
					if = {
						limit = { has_trait = kinslayer_3 }
						add = 20
					}
					if = {
						limit = { has_trait = cannibal }
						add = 20
					}
					if = {
						limit = { has_trait = murderer }
						add = 20
					}
					## Relation to root.
					if = {
						limit = {
							OR = {
								has_any_relation_trigger = { CHARACTER = root }
								is_consort_of = root
								is_close_or_extended_family_of = root
							}
						}
						# We add a flat large number for all so that we can still sort within this boosted list by the rest of our factors.
						add = 1000
					}
				}
				save_scope_as = recidivist
			}
		}
		## But if we don't find anyone, then we create someone.
		if = {
			limit = {
				NOT = { exists = scope:recidivist }
			}
			random_list = {
				100 = {
					create_character = {
						template = criminal_brains_character
						location = scope:destination_1.title_province
						save_scope_as = recidivist
						intrigue = {
							min_template_very_high_skill
							max_template_very_high_skill
						}
						martial = {
							min_template_high_skill
							max_template_high_skill
						}
						prowess = {
							min_template_decent_skill
							max_template_decent_skill
						}
					}
				}
				100 = {
					create_character = {
						template = criminal_brawn_character
						location = scope:destination_1.title_province
						save_scope_as = recidivist
						prowess = {
							min_template_very_high_skill
							max_template_very_high_skill
						}
						martial = {
							min_template_high_skill
							max_template_high_skill
						}
						intrigue = {
							min_template_decent_skill
							max_template_decent_skill
						}
					}
				}
				100 = {
					create_character = {
						template = criminal_fingers_character
						location = scope:destination_1.title_province
						save_scope_as = recidivist
						martial = {
							min_template_very_high_skill
							max_template_very_high_skill
						}
						intrigue = {
							min_template_high_skill
							max_template_high_skill
						}
						prowess = {
							min_template_decent_skill
							max_template_decent_skill
						}
					}
				}
			}
		}
		## If they're not related to us in any way, then try to give them a nickname.
		scope:recidivist = {
			if = {
				limit = {
					NOR = {
						has_any_relation_trigger = { CHARACTER = root }
						is_consort_of = root
						is_close_or_extended_family_of = root
					}
				}
				hidden_effect = { assign_random_nickname_effect = yes }
			}
			add_character_flag = wear_armor
		}
		# Ok, now tag them in the contract so we know to invalidate if something happens to land them or they die _except_ after a duel has begun.
		scope:task_contract = {
			set_variable = {
				name = recidivist
				value = scope:recidivist
			}
		}
		# Plus, if they weren't a criminal, make 'em one.
		scope:recidivist = {
			if = {
				limit = {
					NOT = { has_trait = gallowsbait }
				}
				hidden_effect = {
					add_trait = gallowsbait
					random_list = {
						100 = {
							add_trait_xp = {
								trait = gallowsbait
								track = bandit
								value = {
									integer_range = {
										min = @laamp_base_contract_schemes_1004_gallowsbait_xp_min_value
										max = @laamp_base_contract_schemes_1004_gallowsbait_xp_max_value
									}
								}
							}
						}
						100 = {
							add_trait_xp = {
								trait = gallowsbait
								track = poacher
								value = {
									integer_range = {
										min = @laamp_base_contract_schemes_1004_gallowsbait_xp_min_value
										max = @laamp_base_contract_schemes_1004_gallowsbait_xp_max_value
									}
								}
							}
						}
						100 = {
							add_trait_xp = {
								trait = gallowsbait
								track = marauder
								value = {
									integer_range = {
										min = @laamp_base_contract_schemes_1004_gallowsbait_xp_min_value
										max = @laamp_base_contract_schemes_1004_gallowsbait_xp_max_value
									}
								}
							}
						}
					}
				}
			}
		}
		# Finally, set up our recruitment scopes for later so that we roll consistent numbers.
		save_scope_value_as = {
			name = maa_bandits_count
			value = {
				integer_range = {
					min = 2
					max = 5
				}
			}
		}
		save_scope_value_as = {
			name = maa_poachers_count
			value = {
				integer_range = {
					min = 2
					max = 5
				}
			}
		}
		save_scope_value_as = {
			name = maa_marauders_count
			value = {
				integer_range = {
					min = 2
					max = 5
				}
			}
		}
		save_scope_value_as = {
			name = maa_thieves_count
			value = {
				integer_range = {
					min = 2
					max = 5
				}
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.1004.a

		custom_tooltip = travel.stationary_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.1004.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.1004.tt.explanation
		laamp_base_contract_schemes_1004_organise_travel_effect = {
			DOMICILE = no
			RETURN = yes
			EVENT_FIRE = all_but_last
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.1004.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.1004.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.1004.tt.explanation
		laamp_base_contract_schemes_1004_organise_travel_effect = {
			DOMICILE = yes
			RETURN = no
			EVENT_FIRE = all
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.1005 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_2001 }
			save_scope_as = task_contract
		}
		send_interface_message = {
			title = contract_invalidated_title
			type = stewardship_contract_scheme_invalidated_message
			right_icon = scope:task_contract.task_contract_employer
			scope:task_contract = { complete_task_contract = failure_standard }
		}
	}
}

##################################################
# Act as hired muscle (setup)
# by Ewan Cowhig Croft
# 1011 - 1020
##################################################

#	Intro event.
laamp_base_contract_schemes.1011 = {
	type = character_event
	title = laamp_base_contract_schemes.1011.t
	desc = laamp_base_contract_schemes.1011.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_vengeful
	}
	right_portrait = {
		character = scope:employer
		animation = schadenfreude
	}
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.1011.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_bodyguard
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.1011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_bodyguard
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.1011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.1012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1012.t
	desc = laamp_base_contract_schemes.1012.desc
	theme = martial
	center_portrait = {
		character = root
		animation = menacing
	}
	right_portrait = {
		character = scope:employer
		animation = betting
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = { add_dread = major_dread_gain }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1012.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.1013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1013.t
	desc = laamp_base_contract_schemes.1013.desc
	theme = martial
	center_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:employer
		animation = disapproval
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_dread = medium_dread_loss
			add_stress = medium_stress_gain
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1013.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Help train local MaA (setup)
# by Ewan Cowhig Croft
# 1021 - 1030
##################################################

#	Intro event.
laamp_base_contract_schemes.1021 = {
	type = character_event
	title = laamp_base_contract_schemes.1021.t
	desc = laamp_base_contract_schemes.1021.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	right_portrait = {
		character = scope:employer
		animation = personality_honorable
	}
	override_background = { reference = courtyard }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.1021.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_wrangler
			add_agent_slot = agent_physic
			# Speed.
			add_agent_slot = agent_drillmaster
			add_agent_slot = agent_drillmaster
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.1021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_wrangler
			add_agent_slot = agent_smith
			add_agent_slot = agent_physic
			# Speed.
			add_agent_slot = agent_drillmaster
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.1021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_drillmaster
			add_agent_slot = agent_drillmaster
			add_agent_slot = agent_planner
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.1022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1022.t
	desc = laamp_base_contract_schemes.1022.desc
	theme = martial
	center_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_1021_success_employer_modifier
				years = 15
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1022.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.1023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1023.t
	desc = laamp_base_contract_schemes.1023.desc
	theme = martial
	center_portrait = {
		character = root
		animation = personality_coward
	}
	right_portrait = {
		character = scope:employer
		animation = disbelief
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_1021_failure_employer_modifier
				years = 15
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1023.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Garrison service (setup)
# by Ewan Cowhig Croft
# 1031 - 1040
##################################################

#	Intro event.
laamp_base_contract_schemes.1031 = {
	type = character_event
	title = laamp_base_contract_schemes.1031.t
	desc = laamp_base_contract_schemes.1031.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = personality_callous
	}
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.1031.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_smith
			add_agent_slot = agent_lookout_success
			# Speed.
			add_agent_slot = agent_drillmaster
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.1031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_smith
			add_agent_slot = agent_lookout_success
			# Speed.
			add_agent_slot = agent_drillmaster
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.1031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_drillmaster
			add_agent_slot = agent_drillmaster
			add_agent_slot = agent_planner
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.1032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1032.t
	desc = laamp_base_contract_schemes.1032.desc
	theme = martial
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = flirtation_left
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_1031_success_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.1033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1033.t
	desc = laamp_base_contract_schemes.1033.desc
	theme = martial
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_1031_failure_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Ambush travellers (setup)
# by Ewan Cowhig Croft
# 1041 - 1050
##################################################

#	Intro event.
laamp_base_contract_schemes.1041 = {
	type = character_event
	title = laamp_base_contract_schemes.1041.t
	desc = laamp_base_contract_schemes.1041.desc
	theme = martial
	left_portrait = {
		character = root
		scripted_animation = bow_drawn
	}
	right_portrait = {
		character = scope:employer
		animation = fear
	}
	override_background = { reference = wilderness }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.1041.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_muscle
			add_agent_slot = agent_outrider
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.1041.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_muscle
			add_agent_slot = agent_outrider
			# Speed.
			add_agent_slot = agent_tracker
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.1041.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_ambusher
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_tracker
			add_agent_slot = agent_footpad
			add_agent_slot = agent_infiltrator
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.1042 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1042.t
	desc = laamp_base_contract_schemes.1042.desc
	theme = martial
	center_portrait = {
		character = root
		animation = hunting_knife_start
	}
	right_portrait = {
		character = scope:employer
		animation = shame
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_1041_success_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1042.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.1043 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1043.t
	desc = laamp_base_contract_schemes.1043.desc
	theme = martial
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		scripted_animation = bow_drawn
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_1041_failure_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.1043.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_1044_organise_travel_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		on_arrival_event = laamp_base_contract_schemes.1781
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.1045
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.1044 = {
	type = character_event
	title = laamp_base_contract_schemes.1044.t
	desc = laamp_base_contract_schemes.1044.desc
	theme = martial
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = fear
	}
	override_background = { reference = bedchamber }

	immediate = {
		if = {
			limit = { exists = scope:employer.capital_county }
			scope:employer.capital_county = { save_scope_as = destination_1 }
		}
		else_if = {
			limit = { exists = scope:employer.location }
			scope:employer.location = { save_scope_as = destination_1 }
		}
		else = {
			location = { save_scope_as = destination_1 }
		}
		# Okay, find a suitable destination.
		scope:destination_1 = {
			# Counts travel a duchy or two over.
			if = {
				limit = { scope:employer.highest_held_title_tier = tier_county }
				duchy = {
					random_title_to_title_neighboring_duchy = {
						random_title_to_title_neighboring_duchy = {
							limit = {
								NOT = { this = scope:employer.capital_county.duchy }
							}
							title_capital_county = { save_scope_as = destination_2 }
						}
					}
				}
			}
			# Dukes travel a kingdom over.
			else_if = {
				limit = { scope:employer.highest_held_title_tier = tier_duchy }
				kingdom = {
					random_title_to_title_neighboring_kingdom = {
						title_capital_county = { save_scope_as = destination_2 }
					}
				}
			}
			# Kings and emperors travel an empire over.
			else = {
				empire = {
					random_title_to_title_neighboring_empire = {
						title_capital_county = { save_scope_as = destination_2 }
					}
				}
			}
		}
		# Work out how many encounters we'll have.
		scope:employer = {
			if = {
				limit = { highest_held_title_tier >= tier_empire }
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounters_max
						VAL = 6
					}
				}
			}
			else_if = {
				limit = { highest_held_title_tier >= tier_kingdom }
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounters_max
						VAL = 5
					}
				}
			}
			else_if = {
				limit = { highest_held_title_tier >= tier_duchy }
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounters_max
						VAL = 4
					}
				}
			}
			else_if = {
				limit = { highest_held_title_tier >= tier_county }
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounters_max
						VAL = 3
					}
				}
			}
		}
		# Right, grab the distance between us and the end zone.
		hidden_effect = {
			start_travel_plan = {
				destination = scope:destination_2.title_province
				travel_with_domicile = no
				return_trip = no
				players_use_planner = no
			}
			save_scope_value_as = {
				name = home_path_length
				value = {
					current_travel_plan = {
						every_future_path_location = { add = 1 }
					}
				}
			}
			current_travel_plan = { abort_travel_plan = yes }
		}
		custom_tooltip = laamp_base_contract_schemes.1044.tt.number_of_encounters
		custom_tooltip = laamp_base_contract_schemes.1044.tt.path_warning
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.1044.a

		custom_tooltip = travel.stationary_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.1044.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.1044.tt.explanation
		laamp_base_contract_schemes_1044_organise_travel_effect = {
			DOMICILE = no
			RETURN = yes
			EVENT_FIRE = all_but_last
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.1044.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.1044.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.1044.tt.explanation
		laamp_base_contract_schemes_1044_organise_travel_effect = {
			DOMICILE = yes
			RETURN = no
			EVENT_FIRE = all
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.1045 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_2001 }
			save_scope_as = task_contract
		}
		send_interface_message = {
			title = contract_invalidated_title
			type = stewardship_contract_scheme_invalidated_message
			right_icon = scope:task_contract.task_contract_employer
			scope:task_contract = { complete_task_contract = failure_standard }
		}
	}
}

##################################################
# EXTRA — MARTIAL

##################################################
# Hunt criminals
# by Ewan Cowhig Croft
# 1301 - 1420
##################################################

scripted_effect laamp_base_contract_schemes_1301_roll_other_duel_effect = {
	# Require a crit success if we've only got one chance left.
	if = {
		limit = {
			scope:task_contract.var:encounters_tally >= 3
			scope:task_contract.var:wins_tally <= 0
		}
		duel = {
			skill = $SKILL$
			target = scope:recidivist
			# Critical victory!
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes_1301.$OPTION$.tt.success_crit
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes_1301.$OPTION$.tt.success
					left_icon = scope:recidivist
					custom_tooltip = laamp_base_contract_schemes.1301.tt.insta_win
					trigger_event = laamp_base_contract_schemes.1302
				}
			}
			# Defeat.
			80 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = laamp_base_contract_schemes_1301.$OPTION$.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes_1301.$OPTION$.tt.failure
					left_icon = scope:recidivist
					custom_tooltip = laamp_base_contract_schemes.1301.b.tt.failure.tt
					if = {
						limit = { scope:task_contract.var:encounters_tally >= 3 }
						trigger_event = laamp_base_contract_schemes.1303
					}
				}
			}
		}
	}
	# Otherwise, do the normal thing.
	else = {
		duel = {
			skill = $SKILL$
			target = scope:recidivist
			# Critical victory!
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes_1301.$OPTION$.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes_1301.$OPTION$.tt.success
					left_icon = scope:recidivist
					custom_tooltip = laamp_base_contract_schemes.1301.tt.insta_win
					trigger_event = laamp_base_contract_schemes.1302
				}
			}
			# Victory!
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes_1301.$OPTION$.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes_1301.$OPTION$.tt.success
					left_icon = scope:recidivist
					custom_tooltip = laamp_base_contract_schemes.1301.tt.score_increased
					increment_variable_effect = {
						VAR = wins_tally
						VAL = 1
					}
					if = {
						limit = { scope:task_contract.var:encounters_tally >= 3 }
						if = {
							limit = { scope:task_contract.var:wins_tally >= 2 }
							trigger_event = laamp_base_contract_schemes.1302
						}
						else = { trigger_event = laamp_base_contract_schemes.1303 }
					}
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = laamp_base_contract_schemes_1301.$OPTION$.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes_1301.$OPTION$.tt.failure
					left_icon = scope:recidivist
					custom_tooltip = laamp_base_contract_schemes.1301.b.tt.failure.tt
					if = {
						limit = { scope:task_contract.var:encounters_tally >= 3 }
						trigger_event = laamp_base_contract_schemes.1303
					}
				}
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_1301_successful_recruitment_effect = {
	scope:task_contract = { complete_task_contract = failure_recruitment }
	add_courtier = scope:recidivist
	reverse_add_opinion = {
		target = scope:recidivist
		modifier = respect_opinion
		opinion = 50
	}
	save_scope_value_as = {
		name = chosen_maa_type
		value = { integer_range = { min = 1 max = 4 } }
	}
	random_list = {
		25 = {
			trigger = { scope:chosen_maa_type = 1 }
			spawn_army = {
				men_at_arms = {
					type = maa_bandits
					stacks = scope:maa_bandits_count
				}
				inheritable = no
				uses_supply = yes
				location = root.location
				name = ep3_gallowsbait_army
			}
		}
		25 = {
			trigger = { scope:chosen_maa_type = 2 }
			spawn_army = {
				men_at_arms = {
					type = maa_poachers
					stacks = scope:maa_poachers_count
				}
				inheritable = no
				uses_supply = yes
				location = root.location
				name = ep3_gallowsbait_army
			}
		}
		25 = {
			trigger = { scope:chosen_maa_type = 3 }
			spawn_army = {
				men_at_arms = {
					type = maa_marauders
					stacks = scope:maa_marauders_count
				}
				inheritable = no
				uses_supply = yes
				location = root.location
				name = ep3_gallowsbait_army
			}
		}
		25 = {
			trigger = { scope:chosen_maa_type = 4 }
			spawn_army = {
				men_at_arms = {
					type = maa_thieves
					stacks = scope:maa_thieves_count
				}
				inheritable = no
				uses_supply = yes
				location = root.location
				name = ep3_gallowsbait_army
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_1301_roll_diplo_duel_effect = {
	duel = {
		skill = diplomacy
		value = $DIFF$
		# Victory!
		50 = {
			compare_modifier = {
				value = {
					value = scope:duel_value
					if = {
						limit = { "opinion(root)" >= 25 }
						add = {
							value = "opinion(root)"
							multiply = 0.5
						}
					}
				}
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.1301.e.tt.success
			show_as_tooltip = { laamp_base_contract_schemes_1301_successful_recruitment_effect = yes }
			trigger_event = laamp_base_contract_schemes.1304
		}
		# Defeat.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.1301.e.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.1301.e.tt.failure
				left_icon = scope:recidivist
				custom_tooltip = laamp_base_contract_schemes.1301.e.tt.failure.tt
				if = {
					limit = { scope:task_contract.var:encounters_tally >= 3 }
					trigger_event = laamp_base_contract_schemes.1303
				}
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_1301_roll_army_loss_effect = {
	random_list = {
		# Catastrophic losses.
		25 = {
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_catastrophic_value
				}
			}
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_catastrophic_value
				}
			}
			min = 5
			modifier = {
				add = scope:recidivist.martial
				always = yes
			}
		}
		# Heavy losses.
		25 = {
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_heavy_value
				}
			}
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_heavy_value
				}
			}
			min = 5
			modifier = {
				add = scope:recidivist.martial
				always = yes
			}
		}
		# Moderate losses.
		50 = {
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_moderate_value
				}
			}
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_moderate_value
				}
			}
			min = 5
			modifier = {
				add = { subtract = scope:recidivist.martial }
				always = yes
			}
		}
		# Light losses.
		50 = {
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_light_value
				}
			}
			random_maa_regiment = {
				change_maa_troops_count = {
					value = maa_current_troops_count
					multiply = laamp_base_contract_schemes_1301_maa_damage_light_value
				}
			}
			min = 5
			modifier = {
				add = { subtract = scope:recidivist.martial }
				always = yes
			}
		}
	}
}

#	Encounter your quarry.
laamp_base_contract_schemes.1301 = {
	type = character_event
	title = laamp_base_contract_schemes.1301.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:task_contract.var:encounters_tally = 1 }
				desc = laamp_base_contract_schemes.1301.desc.intro.preamble.first
			}
			desc = laamp_base_contract_schemes.1301.desc.intro.preamble
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					location = { terrain = plains }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.plains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = farmlands }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.farmlands
			}
			triggered_desc = {
				trigger = {
					location = { terrain = hills }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.hills
			}
			triggered_desc = {
				trigger = {
					location = { terrain = mountains }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.mountains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = desert }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.desert
			}
			triggered_desc = {
				trigger = {
					location = { terrain = desert_mountains }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.desert_mountains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = oasis }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.oasis
			}
			triggered_desc = {
				trigger = {
					location = { terrain = jungle }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.jungle
			}
			triggered_desc = {
				trigger = {
					location = { terrain = forest }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.forest
			}
			triggered_desc = {
				trigger = {
					location = { terrain = taiga }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.taiga
			}
			triggered_desc = {
				trigger = {
					location = { terrain = wetlands }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.wetlands
			}
			triggered_desc = {
				trigger = {
					location = { terrain = steppe }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.steppe
			}
			triggered_desc = {
				trigger = {
					location = { terrain = floodplains }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.floodplains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = drylands }
				}
				desc = laamp_base_contract_schemes.1301.desc.intro.drylands
			}
		}
		desc = laamp_base_contract_schemes.1301.desc.intro.postamble
		desc = boilerplate.paragraph
		first_valid = {
			triggered_desc = {
				trigger = { scope:task_contract.var:encounters_tally = 1 }
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recidivist }
							}
							desc = laamp_base_contract_schemes.1301.desc.encounters.first.relation.good
						}
						triggered_desc = {
							trigger = {
								OR = {
									has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recidivist }
									scope:recidivist = { has_relation_grudge = root }
								}
							}
							desc = laamp_base_contract_schemes.1301.desc.encounters.first.relation.bad
						}
						triggered_desc = {
							trigger = { is_close_or_extended_family_of = scope:recidivist }
							desc = laamp_base_contract_schemes.1301.desc.encounters.first.family
						}
						desc = {
							random_valid = {
								desc = laamp_base_contract_schemes.1301.desc.encounters.first.general_reaction.angry
								desc = laamp_base_contract_schemes.1301.desc.encounters.first.general_reaction.haughty
								desc = laamp_base_contract_schemes.1301.desc.encounters.first.general_reaction.doleful
								desc = laamp_base_contract_schemes.1301.desc.encounters.first.general_reaction.merry
								desc = laamp_base_contract_schemes.1301.desc.encounters.first.general_reaction.taciturn
							}
						}
					}
				}
			}
			triggered_desc = {
				trigger = { scope:task_contract.var:encounters_tally = 2 }
				desc = laamp_base_contract_schemes.1301.desc.encounters.second
			}
			triggered_desc = {
				trigger = { scope:task_contract.var:encounters_tally = 3 }
				desc = laamp_base_contract_schemes.1301.desc.encounters.third
			}
		}
		desc = boilerplate.paragraph
		random_valid = {
			desc = laamp_base_contract_schemes.1301.desc.outro.1
			desc = laamp_base_contract_schemes.1301.desc.outro.2
			desc = laamp_base_contract_schemes.1301.desc.outro.3
			desc = laamp_base_contract_schemes.1301.desc.outro.4
			desc = laamp_base_contract_schemes.1301.desc.outro.5
		}
	}
	theme = martial
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:recidivist
		animation = aggressive_sword
	}
	override_background = { reference = wilderness }

	trigger = {
		scope:recidivist = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		# One more encounter!
		scope:task_contract = {
			increment_variable_effect = {
				VAR = encounters_tally
				VAL = 1
			}
		}
		# Update the player on their score.
		custom_tooltip = laamp_base_contract_schemes.1301.tt.success_score_and_threshold
		custom_tooltip = laamp_base_contract_schemes.1301.tt.chances_remaining
		# Teleport our dude over here.
		hidden_effect = {
			scope:recidivist = {
				set_location = {
					location = root.location
					stick_to_location = yes
				}
			}
		}
		# Nab our current county for loc.
		location.county = { save_scope_as = current_county }
	}

	# Prowess: SCE.
	option = {
		name = laamp_base_contract_schemes.1301.a
		trigger = {
			can_start_single_combat_trigger = yes
			# Tell the AI not to kill itself if it sucks.
			trigger_if = {
				limit = { is_ai = yes }
				prowess >= @laamp_base_contract_schemes_1301_ai_min_prowess_value
			}
		}
		skill = prowess

		save_scope_value_as = {
			name = method
			value = flag:prowess_sce
		}
		custom_tooltip = laamp_base_contract_schemes.1301.a.tt.duel_begins
		scope:task_contract = { set_variable = duel_engaged }
		if = {
			limit = { is_ai = no }
			configure_start_single_combat_effect = {
				SC_INITIATOR = root
				SC_ATTACKER = root
				SC_DEFENDER = scope:recidivist
				FATALITY = always
				FIXED = no
				LOCALE = terrain_scope
				INVALIDATION_EVENT = single_combat.1006
				OUTPUT_EVENT = laamp_base_contract_schemes.1305
			}
		}
		else = {
			configure_start_single_combat_effect = {
				SC_INITIATOR = root
				SC_ATTACKER = root
				SC_DEFENDER = scope:recidivist
				FATALITY = possible
				FIXED = no
				LOCALE = terrain_scope
				INVALIDATION_EVENT = single_combat.1006
				OUTPUT_EVENT = laamp_base_contract_schemes.1305
			}
		}

		stress_impact = {
			brave = minor_stress_impact_loss
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = prowess
					subtract = scope:recidivist.prowess
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Prowess: regular skill duel.
	option = {
		name = laamp_base_contract_schemes.1301.b
		trigger = {
			can_start_single_combat_trigger = no
			# Tell the AI not to kill itself if it sucks.
			trigger_if = {
				limit = { is_ai = yes }
				prowess < @laamp_base_contract_schemes_1301_ai_min_prowess_value
			}
		}
		skill = prowess

		save_scope_value_as = {
			name = method
			value = flag:prowess_non_sce
		}
		laamp_base_contract_schemes_1301_roll_other_duel_effect = {
			SKILL = prowess
			OPTION = b
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = prowess
					subtract = scope:recidivist.prowess
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Martial.
	option = {
		name = laamp_base_contract_schemes.1301.c
		skill = martial

		save_scope_value_as = {
			name = method
			value = flag:martial
		}
		laamp_base_contract_schemes_1301_roll_other_duel_effect = {
			SKILL = martial
			OPTION = c
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = martial
					subtract = scope:recidivist.martial
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Throw troops at them.
	option = {
		name = laamp_base_contract_schemes.1301.d
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.1301.d.tt.not_enough_troops
				current_military_strength >= laamp_base_contract_schemes_1301_min_troops_value
			}
			has_raised_armies = no
		}
		show_as_unavailable = { always = yes }

		save_scope_value_as = {
			name = method
			value = flag:meat
		}
		custom_tooltip = laamp_base_contract_schemes.1301.tt.insta_win
		show_as_tooltip = { laamp_base_contract_schemes_1301_roll_army_loss_effect = yes }
		trigger_event = laamp_base_contract_schemes.1302

		# No stress here.
		# If you can auto-win, strongly consider it.
		ai_chance = { base = 100 }
	}
	
	# Diplo duel (bandit version).
	option = {
		name = laamp_base_contract_schemes.1301.e
		trigger = {
			has_realm_law = camp_purpose_brigands
			NOT = {
				# Scope into them to account for grudges.
				scope:recidivist = {
					has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = root }
				}
			}
		}
		reason = purpose_brigands

		save_scope_value_as = {
			name = method
			value = flag:diplo_bandit
		}
		laamp_base_contract_schemes_1301_roll_diplo_duel_effect = { DIFF = high_skill_rating }

		stress_impact = {
			trusting = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Diplo duel (non-criminal version).
	option = {
		name = laamp_base_contract_schemes.1301.f
		trigger = {
			NOR = {
				has_realm_law = camp_purpose_brigands
				scope:recidivist = {
					has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = root }
				}
			}
		}
		show_as_unavailable = {
			NOT = { has_realm_law = camp_purpose_brigands }
		}
		skill = diplomacy

		save_scope_value_as = {
			name = method
			value = flag:diplo_non_bandit
		}
		laamp_base_contract_schemes_1301_roll_diplo_duel_effect = { DIFF = extremely_high_skill_rating }

		stress_impact = {
			trusting = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
}

#	You brought them down.
laamp_base_contract_schemes.1302 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1302.t
	desc = {
		desc = laamp_base_contract_schemes.1302.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:method = flag:prowess_sce }
				desc = laamp_base_contract_schemes.1302.desc.method.prowess_sce
			}
			triggered_desc = {
				trigger = { scope:method = flag:prowess_non_sce }
				desc = laamp_base_contract_schemes.1302.desc.method.prowess_non_sce
			}
			triggered_desc = {
				trigger = { scope:method = flag:martial }
				desc = laamp_base_contract_schemes.1302.desc.method.martial
			}
			triggered_desc = {
				trigger = { scope:method = flag:meat }
				desc = laamp_base_contract_schemes.1302.desc.method.meat
			}
		}
		desc = laamp_base_contract_schemes.1302.desc.outro
	}
	theme = martial
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:recidivist
		animation = map_fear
	}
	override_background = { reference = throne_room }

	immediate = {
		scope:task_contract = { complete_task_contract = success_standard }
		# If we need to take loss, take them.
		if = {
			limit = { scope:method = flag:meat }
			laamp_base_contract_schemes_1301_roll_army_loss_effect = yes
		}
		# If they're alive, now we kill them.
		scope:recidivist = {
			if = {
				limit = { is_alive = yes }
				death = {
					death_reason = death_battle
					killer = root
				}
			}
		}
		hidden_effect = {
			return_home = yes
		}
	}

	# Collect the head and go.
	option = {
		name = laamp_base_contract_schemes.1302.a
		
		custom_tooltip = laamp_base_contract_schemes.1302.a.tt

		# No stress, no AI.
	}
}

#	They evade you.
laamp_base_contract_schemes.1303 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1303.t
	desc = {
		desc = laamp_base_contract_schemes.1303.desc.intro
		first_valid = {
			# No SCE loss loc: if you lost the duel, you're already dead.
			triggered_desc = {
				trigger = { scope:method = flag:prowess_non_sce }
				desc = laamp_base_contract_schemes.1303.desc.method.prowess_non_sce
			}
			triggered_desc = {
				trigger = { scope:method = flag:martial }
				desc = laamp_base_contract_schemes.1303.desc.method.martial
			}
			triggered_desc = {
				trigger = { scope:method = flag:diplo_bandit }
				desc = laamp_base_contract_schemes.1303.desc.method.diplo_bandit
			}
			triggered_desc = {
				trigger = { scope:method = flag:diplo_non_bandit }
				desc = laamp_base_contract_schemes.1303.desc.method.diplo_non_bandit
			}
		}
		desc = boilerplate.paragraph
		desc = laamp_base_contract_schemes.1303.desc.outro
	}
	theme = martial
	left_portrait = {
		character = scope:employer
		animation = dismissal
	}
	center_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:recidivist
		animation = schadenfreude
	}
	override_background = { reference = throne_room }

	immediate = {
		scope:task_contract = { complete_task_contract = failure_standard }
	}

	# Drat!
	option = {
		name = laamp_base_contract_schemes.1303.a
		
		custom_tooltip = laamp_base_contract_schemes.1303.a.tt

		# No stress, no AI.
	}
}

#	You recruited them, despite your orders.
laamp_base_contract_schemes.1304 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1304.t
	desc = laamp_base_contract_schemes.1304.desc
	theme = martial
	left_portrait = {
		character = scope:employer
		animation = anger
	}
	center_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:recidivist
		animation = admiration
	}
	override_background = { reference = throne_room }

	immediate = {
		laamp_base_contract_schemes_1301_successful_recruitment_effect = yes
	}

	# Eh, I still win.
	option = {
		name = laamp_base_contract_schemes.1304.a
		
		custom_tooltip = laamp_base_contract_schemes.1304.a.tt

		# No stress, no AI.
	}

	after = {
		hidden_effect = {
			return_home = yes
		}
	}
}

# Combat outcome event.
laamp_base_contract_schemes.1305 = {
	hidden = yes

	immediate = {
		# You lost, they're a bandit.
		if = {
			limit = { scope:sc_victor = scope:recidivist }
			scope:recidivist = {
				add_trait_xp = {
					trait = gallowsbait
					track = bandit
					value = 10
				}
			}
			# Account for surviving AI, as the AI gets kiddy-gloves and doesn't die here.
			scope:sc_loser = {
				if = {
					limit = {
						is_alive = yes
						is_ai = yes
					}
					trigger_event = laamp_base_contract_schemes.1303
				}
			}
		}
		# You won, spin on through.
		else = {
			scope:sc_victor = { trigger_event = laamp_base_contract_schemes.1302 }
		}
	}
}

##################################################
# Ambush travellers
# by Ewan Cowhig Croft
# 1781 - 1900
##################################################

#	Travel processing event.
laamp_base_contract_schemes.1781 = {
	hidden = yes

	immediate = {
		# If this is us reaching the start of our route, then flag that we want to start ambushing people.
		current_travel_plan = {
			if = {
				limit = {
					NOT = { has_variable = activate_laamp_base_1041_logic }
				}
				# Tell the on_action logic to activate.
				set_variable = activate_laamp_base_1041_logic
				root = {
					set_variable = {
						name = laamp_base_1041_travel_plan_contract_storage
						value = scope:task_contract
					}
				}
				# Calculate our path length.
				save_scope_value_as = {
					name = path_length_temp
					value = {
						every_future_path_location = { add = 1 }
						# Deduct the end locations.
						add = -1
						# And deduct our route on the way.
						subtract = scope:home_path_length
					}
				}
				# Aaand sort our provinces-per-event ratio.
				save_scope_value_as = {
					name = event_ratio_temp
					value = {
						value = scope:path_length_temp
						divide = scope:task_contract.var:encounters_max
						# Make it just a smidge faster, so that we're done by the time we get to our final destination.
						add = -1
						floor = yes
						min = 1
					}
				}
				scope:task_contract = {
					increment_variable_effect = {
						VAR = path_length
						VAL = scope:path_length_temp
					}
					increment_variable_effect = {
						VAR = event_ratio
						VAL = scope:event_ratio_temp
					}
					increment_variable_effect = {
						VAR = event_ratio_tracker
						VAL = scope:event_ratio_temp
					}
				}
			}
			else = {
				if = {
					limit = { scope:task_contract.var:haul_actual >= 1 }
					travel_plan_owner = { trigger_event = laamp_base_contract_schemes.1783 }
				}
				else = {
					travel_plan_owner = { trigger_event = laamp_base_contract_schemes.1784 }
				}
			}
		}
	}
}

scripted_trigger laamp_base_contract_schemes_1782_valid_target_char_trigger = {
	is_healthy = yes
	is_adult = yes
	is_ai = yes
	gold >= @laamp_base_contract_schemes_1782_min_gold_value
	NOR = {
		save_temporary_scope_as = char_temp
		scope:task_contract = {
			is_target_in_variable_list = {
				name = previous_victims_list
				target = scope:char_temp
			}
		}
		liege = root
	}
}

scripted_effect laamp_base_contract_schemes_1782_roll_duel_effect = {
	duel = {
		skill = $SKILL$
		value = $DIFF$
		# Victory!
		$WIN_CHANCE$ = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 10
			desc = laamp_base_contract_schemes.1782.$OPTION$.tt.success
			send_interface_toast = {
				type = event_generic_good
				title = laamp_base_contract_schemes.1782.$OPTION$.tt.success
				left_icon = scope:victim
				scope:victim = {
					pay_short_term_gold = {
						target = root
						gold = $GOLD$
					}
					progress_towards_rival_effect = {
						REASON = rival_robbed_me
						CHARACTER = root
						OPINION = 0
					}
				}
			}
			reverse_add_opinion = {
				target = scope:victim
				modifier = gallowsbait_scum_opinion
				opinion = -50
			}
			laamp_rewards_apply_criminal_xp_effect = {
				TRACK = bandit
				XP_MAX = scope:gallowsbait_xp_win
				XP_MIN = scope:gallowsbait_xp_win
			}
			root.var:laamp_base_1041_travel_plan_contract_storage = {
				increment_variable_effect = {
					VAR = haul_actual
					VAL = $GOLD$
				}
			}
		}
		# Defeat.
		$LOSE_CHANCE$ = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 10
			desc = laamp_base_contract_schemes.1782.$OPTION$.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.1782.$OPTION$.tt.failure
				left_icon = scope:victim
				custom_tooltip = laamp_base_contract_schemes.1782.tt.victim_escapes
				progress_towards_rival_effect = {
					REASON = rival_attempted_to_rob_me
					CHARACTER = root
					OPINION = 0
				}
			}
			reverse_add_opinion = {
				target = scope:victim
				modifier = gallowsbait_scum_opinion
				opinion = -25
			}
			laamp_rewards_apply_criminal_xp_effect = {
				TRACK = bandit
				XP_MAX = scope:gallowsbait_xp_lose
				XP_MIN = scope:gallowsbait_xp_lose
			}
		}
	}
}

#	You accost someone along the road.
laamp_base_contract_schemes.1782 = {
	type = character_event
	title = laamp_base_contract_schemes.1782.t
	desc = {
		random_valid = {
			desc = laamp_base_contract_schemes.1782.desc.intro.1
			desc = laamp_base_contract_schemes.1782.desc.intro.2
			desc = laamp_base_contract_schemes.1782.desc.intro.3
			desc = laamp_base_contract_schemes.1782.desc.intro.4
			desc = laamp_base_contract_schemes.1782.desc.intro.5
		}
		# Do we know the person?
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:victim }
				}
				desc = laamp_base_contract_schemes.1782.desc.connection.negative
			}
			triggered_desc = {
				trigger = {
					has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:victim }
				}
				desc = laamp_base_contract_schemes.1782.desc.connection.positive
			}
			triggered_desc = {
				trigger = { is_consort_of = scope:victim }
				desc = laamp_base_contract_schemes.1782.desc.connection.family_or_consort
			}
			desc = laamp_base_contract_schemes.1782.desc.connection.none
		}
		desc = boilerplate.paragraph
		# What type of person are they?
		first_valid = {
			triggered_desc = {
				trigger = { scope:victim_type = flag:pool }
				desc = laamp_base_contract_schemes.1782.desc.victim_type.pool
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:baron }
				desc = laamp_base_contract_schemes.1782.desc.victim_type.baron
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:travelling_ruler }
				desc = laamp_base_contract_schemes.1782.desc.victim_type.travelling_ruler
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:travelling_nobody }
				desc = laamp_base_contract_schemes.1782.desc.victim_type.travelling_nobody
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:laamp }
				desc = laamp_base_contract_schemes.1782.desc.victim_type.laamp
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:fallback }
				desc = laamp_base_contract_schemes.1782.desc.victim_type.fallback
			}
		}
		desc = boilerplate.paragraph
		desc = laamp_base_contract_schemes.1782.desc.outro
	}
	theme = martial
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:victim
		animation = happiness
	}
	override_background = { reference = wilderness }

	immediate = {
		# Nab our contract.
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_1041 }
			save_scope_as = task_contract
		}
		# Alright, gather our potential victims.
		## First we wipe anyone who might've been here to begin with.
		every_in_list = {
			list = potential_chars_list
			remove_from_list = potential_chars_list
		}
		## Pool chars.
		### Current location.
		every_pool_character = {
			province = root.location
			limit = { laamp_base_contract_schemes_1782_valid_target_char_trigger = yes }
			add_to_list = potential_chars_list
			add_to_list = is_pool_char_list
		}
		### Neighbouring locations.
		location.duchy = {
			every_title_to_title_neighboring_and_across_water_duchy = {
				title_capital_county.title_province = { save_scope_as = province_temp }
				every_pool_character = {
					province = scope:province_temp
					limit = { laamp_base_contract_schemes_1782_valid_target_char_trigger = yes }
					add_to_list = potential_chars_list
					add_to_list = is_pool_char_list
				}
			}
		}
		## Local barons & passers by.
		location.duchy = {
			every_dejure_vassal_title_holder = {
				limit = { highest_held_title_tier = tier_barony }
				# Grab suitable barons.
				if = {
					limit = {
						laamp_base_contract_schemes_1782_valid_target_char_trigger = yes
						is_available = yes
					}
					add_to_list = potential_chars_list
					add_to_list = is_baron_char_list
				}
				# And available travellers.
				primary_title.title_province = {
					every_character_in_location = {
						limit = {
							laamp_base_contract_schemes_1782_valid_target_char_trigger = yes
							is_travelling = yes
							is_landless_adventurer = no
						}
						save_scope_as = potential_chars_list
						add_to_list = is_travelling_char_list
					}
				}
			}
		}
		## Fellow laamps.
		### There can be quite a few of these, so we only check such for players and notable laamps.
		if = {
			limit = {
				OR = {
					is_ai = no
					prestige_level >= high_prestige_level
				}
			}
			every_in_global_list = {
				variable = laamps_tally
				limit = {
					domicile = {
						domicile_location.duchy = root.location.duchy
						# Laamps with defences can't be ambushed — partially for verisimilitude, partially just to keep loc variants down.
						NOT = { has_domicile_building_or_higher = camp_perimeter_01 }
					}
					laamp_base_contract_schemes_1782_valid_target_char_trigger = yes
					NOT = { this = root }
				}
				save_scope_as = potential_chars_list
				add_to_list = is_laamp_char_list
			}
		}
		# Aaaand process them to pick out the one we want.
		random_in_list = {
			list = potential_chars_list
			weight = {
				# Take our wealth as the standard measurement.
				modifier = {
					add = {
						value = gold
						subtract = @laamp_base_contract_schemes_1782_min_gold_value
					}
					always = yes
				}
				# Then we really want to get people travelling if we can.
				modifier = {
					add = 250
					is_travelling = yes
				}
				# And anyone who _isn't_ a baron is a great target.
				modifier = {
					add = {
						value = highest_held_title_tier
						multiply = 100
					}
					is_ruler = yes
				}
				# Finally, hyper-prio other laamps, as that helps the world feel alive.
				modifier = {
					add = 1000
					is_landless_adventurer = yes
				}
			}
			save_scope_as = victim
			# Log them as someone we shouldn't rob again this contract.
			scope:task_contract = {
				add_to_variable_list = {
					name = previous_victims_list
					target = scope:victim
				}
			}
		}
		## If we managed to _not_ grab anyone, then generate someone as a fallback.
		if = {
			limit = {
				NOT = { exists = scope:victim }
			}
			create_character = {
				template = merchant_template
				culture = location.culture
				faith = location.faith
				location = root.location
				save_scope_as = victim
			}
		}
		hidden_effect = {
			scope:victim = {
				if = {
					limit = {
						gold < 50
					}
					add_gold = {
						value = {
							integer_range = {
								min = 50
								max = 200
							}
						}
					}
				}
			}
		}
		# Cool, now that we've got a victim, let's set up some scopes derived from them.
		## See what list they came from for the desc.
		scope:victim = {
			switch = {
				trigger = is_in_list
				is_pool_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:pool
					}
				}
				is_baron_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:baron
					}
				}
				is_travelling_char_list = {
					if = {
						limit = { is_ruler = yes }
						save_scope_value_as = {
							name = victim_type
							value = flag:travelling_ruler
						}
					}
					else = {
						save_scope_value_as = {
							name = victim_type
							value = flag:travelling_nobody
						}
					}
				}
				is_laamp_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:laamp
					}
				}
				fallback = {
					save_scope_value_as = {
						name = victim_type
						value = flag:fallback
					}
				}
			}
		}
		## Plus set up how much gold we might be able to purloin from them.
		save_scope_value_as = {
			name = haul
			value = {
				value = scope:victim.gold
				multiply = 0.2
				min = 50
				max = {
					value = scope:victim.highest_held_title_tier
					multiply = 100
					min = 100
				}
			}
		}
		save_scope_value_as = {
			name = haul_half
			value = {
				value = scope:haul
				multiply = 0.5
				ceiling = yes
			}
		}
		## And what our gallowbait gain would be.
		save_scope_value_as = {
			name = gallowsbait_xp_win
			value = {
				add = scope:victim.highest_held_title_tier
				add = 1
			}
		}
		save_scope_value_as = {
			name = gallowsbait_xp_lose
			value = {
				add = scope:gallowsbait_xp_win
				multiply = 0.5
				floor = yes
				min = 1
			}
		}
		## Finally, check our skills for the duel diffs.
		save_scope_value_as = {
			name = prowess_diff
			value = {
				add = scope:victim.prowess
				add = highest_held_title_tier
				min = high_skill_rating
			}
		}
		save_scope_value_as = {
			name = martial_diff
			value = {
				add = scope:victim.martial
				add = highest_held_title_tier
				min = high_skill_rating
			}
		}
		save_scope_value_as = {
			name = intrigue_diff
			value = {
				add = scope:victim.intrigue
				add = highest_held_title_tier
				min = decent_skill_rating
			}
		}
	}

	# Prowess duel — default.
	option = {
		name = laamp_base_contract_schemes.1782.a
		skill = prowess

		laamp_base_contract_schemes_1782_roll_duel_effect = {
			SKILL = prowess
			DIFF = scope:prowess_diff
			WIN_CHANCE = 50
			LOSE_CHANCE = 50
			OPTION = a
			GOLD = scope:haul
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = prowess
					subtract = scope:victim.prowess
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Martial duel — default.
	option = {
		name = laamp_base_contract_schemes.1782.b
		skill = martial

		laamp_base_contract_schemes_1782_roll_duel_effect = {
			SKILL = martial
			DIFF = scope:martial_diff
			WIN_CHANCE = 50
			LOSE_CHANCE = 50
			OPTION = b
			GOLD = scope:haul
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = martial
					subtract = scope:victim.martial
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Intrigue duel — easier, but lower returns.
	option = {
		name = laamp_base_contract_schemes.1782.c
		skill = intrigue

		custom_tooltip = laamp_base_contract_schemes.1782.c.tt.easier_against_most_but_less_rewards
		laamp_base_contract_schemes_1782_roll_duel_effect = {
			SKILL = intrigue
			DIFF = scope:intrigue_diff
			WIN_CHANCE = 60
			LOSE_CHANCE = 40
			OPTION = c
			GOLD = scope:haul_half
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = intrigue
					subtract = scope:victim.intrigue
					multiply = 5
				}
				always = yes
			}
			ai_value_modifier = { ai_greed = -0.2 }
		}
	}
	
	# Leave this one alone.
	option = {
		name = laamp_base_contract_schemes.1782.d

		custom_tooltip = laamp_base_contract_schemes.1782.d.tt
		reverse_add_opinion = {
			target = scope:victim
			modifier = friendly_face_on_the_road_opinion
			opinion = 10
		}

		stress_impact = {
			just = miniscule_stress_impact_loss
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = 1 }
		}
	}
}

# You stole at least some money.
laamp_base_contract_schemes.1783 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.1783.t
	desc = laamp_base_contract_schemes.1783.desc
	theme = martial
	left_portrait = {
		character = root
		animation = steward
	}
	override_background = { reference = throne_room }

	immediate = {
		save_scope_value_as = {
			name = suppress_gold_warning
			value = yes
		}
		var:laamp_base_1041_travel_plan_contract_storage = { complete_task_contract = success_standard }
		current_travel_plan ?= { remove_variable = activate_laamp_base_1041_logic }
	}

	# Ayyy we're the best.
	option = {
		name = laamp_base_contract_schemes.1783.a

		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}
}

# You managed to steal zero money.
laamp_base_contract_schemes.1784 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.1784.t
	desc = laamp_base_contract_schemes.1784.desc
	theme = martial
	left_portrait = {
		character = root
		animation = stress
	}
	override_background = { reference = throne_room }

	immediate = {
		save_scope_value_as = {
			name = suppress_gold_warning
			value = yes
		}
		var:laamp_base_1041_travel_plan_contract_storage = { complete_task_contract = failure_standard }
		current_travel_plan ?= { remove_variable = activate_laamp_base_1041_logic }
	}

	# Christ we suck.
	option = {
		name = laamp_base_contract_schemes.1784.a

		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}
}














##################################################
# SETUP — STEWARDSHIP

##################################################
# Collect taxes for a third party (setup)
# by Ewan Cowhig Croft
# 2001 - 2010
##################################################

#	Intro event.
laamp_base_contract_schemes.2001 = {
	type = character_event
	title = laamp_base_contract_schemes.2001.t
	desc = laamp_base_contract_schemes.2001.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_callous
	}
	right_portrait = {
		character = scope:employer
		animation = personality_bold
	}
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.2001.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_bailiff
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.2001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_bailiff
			add_agent_slot = agent_muscle
			add_agent_slot = agent_bodyguard
			# Speed.
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.2001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_herald
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.2002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.2002.t
	desc = laamp_base_contract_schemes.2002.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:employer
		animation = happiness
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_gold = {
				value = scope:task_contract.task_contract_taker.task_contract_success_gold_gain_full_value
				multiply = 2
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.2003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.2003.t
	desc = laamp_base_contract_schemes.2003.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = { add_stress = major_stress_gain }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_2004_organise_travel_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		on_arrival_event = laamp_base_contract_schemes.2301
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.2005
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.2004 = {
	type = character_event
	title = laamp_base_contract_schemes.2004.t
	desc = laamp_base_contract_schemes.2004.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	lower_center_portrait = scope:person_a
	override_background = { reference = bedchamber }

	immediate = {
		scope:person_a.primary_title = { save_scope_as = destination_1 }
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.2004.a

		custom_tooltip = travel.stationary_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.2004.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.2004.tt.explanation
		laamp_base_contract_schemes_2004_organise_travel_effect = {
			DOMICILE = no
			RETURN = yes
			EVENT_FIRE = all_but_last
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.2004.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.2004.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.2004.tt.explanation
		laamp_base_contract_schemes_2004_organise_travel_effect = {
			DOMICILE = yes
			RETURN = no
			EVENT_FIRE = all
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.2005 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_2001 }
			save_scope_as = task_contract
		}
		send_interface_message = {
			title = contract_invalidated_title
			type = stewardship_contract_scheme_invalidated_message
			desc = contract_invalidated_desc
			right_icon = scope:task_contract.task_contract_employer
			scope:task_contract = { complete_task_contract = failure_standard }
		}
	}
}

##################################################
# Perform a census (setup)
# by Ewan Cowhig Croft
# 2011 - 2020
##################################################

#	Intro event.
laamp_base_contract_schemes.2011 = {
	type = character_event
	title = laamp_base_contract_schemes.2011.t
	desc = laamp_base_contract_schemes.2011.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:employer
		animation = page_flipping
	}
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.2011.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_bailiff
			# Speed.
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_herald
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.2011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_bailiff
			add_agent_slot = agent_bodyguard
			# Speed.
			add_agent_slot = agent_planner
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.2011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			# Speed.
			add_agent_slot = agent_planner
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_herald
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.2012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.2012.t
	desc = laamp_base_contract_schemes.2012.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = personality_greedy
	}
	right_portrait = {
		character = scope:employer
		animation = writing
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			every_held_county = {
				custom = custom.every_domain_county
				change_county_control = medium_county_control_gain
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2012.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.2013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.2013.t
	desc = laamp_base_contract_schemes.2013.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:employer
		animation = disapproval
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			every_held_county = {
				custom = custom.every_domain_county
				change_county_control = medium_county_control_loss
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2013.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_2014_organise_travel_effect = {
	switch = {
		trigger = exists
		scope:destination_12 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.12_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				destination = scope:destination_7.title_province
				destination = scope:destination_8.title_province
				destination = scope:destination_9.title_province
				destination = scope:destination_10.title_province
				destination = scope:destination_11.title_province
				destination = scope:destination_12.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_11 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.11_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				destination = scope:destination_7.title_province
				destination = scope:destination_8.title_province
				destination = scope:destination_9.title_province
				destination = scope:destination_10.title_province
				destination = scope:destination_11.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_10 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.10_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				destination = scope:destination_7.title_province
				destination = scope:destination_8.title_province
				destination = scope:destination_9.title_province
				destination = scope:destination_10.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_9 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.09_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				destination = scope:destination_7.title_province
				destination = scope:destination_8.title_province
				destination = scope:destination_9.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_8 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.08_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				destination = scope:destination_7.title_province
				destination = scope:destination_8.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_7 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.07_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				destination = scope:destination_7.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_6 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.06_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				destination = scope:destination_6.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_5 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.05_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				destination = scope:destination_5.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_4 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.04_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				destination = scope:destination_4.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
		scope:destination_3 = {
			custom_tooltip = laamp_base_contract_schemes.2014.tt.destination_list.03_destinations
			start_travel_plan = {
				destination = scope:destination_1.title_province
				destination = scope:destination_2.title_province
				destination = scope:destination_3.title_province
				on_arrival_event = laamp_base_contract_schemes.2541
				travel_with_domicile = $DOMICILE$
				return_trip = $RETURN$
				on_travel_planner_cancel_event = laamp_base_contract_schemes.2015
				players_use_planner = no
				on_arrival_destinations = $EVENT_FIRE$
			}
		}
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.2014 = {
	type = character_event
	title = laamp_base_contract_schemes.2014.t
	desc = laamp_base_contract_schemes.2014.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = steward
	}
	override_background = { reference = wilderness }

	immediate = {
		scope:employer = {
			# Grab all possible destinations.
			every_sub_realm_county = {
				limit = {
					any_county_province = {
						NOT = { this = root.domicile.domicile_location }
					}
				}
				add_to_list = travellable_counties_list
			}
			every_sub_realm_barony = {
				limit = {
					exists = holder
					holder.highest_held_title_tier = tier_barony
					NOT = { title_province = root.domicile.domicile_location }
				}
				add_to_list = travellable_baronies_list
			}
			# Now, try to pick out valid destinations.
			## Preferring counties.
			ordered_in_list = {
				list = travellable_counties_list
				order_by = development_level
				max = laamp_base_2011_desired_surveyable_holdings_per_tier_value
				check_range_bounds = no
				add_to_list = destinations_list
			}
			## But allowing baronies if we run out.
			if = {
				limit = { "list_size(destinations_list)" < laamp_base_2011_desired_surveyable_holdings_per_tier_value }
				ordered_in_list = {
					list = travellable_baronies_list
					order_by = county.development_level
					limit = {
						county = { save_temporary_scope_as = county_temp }
						NOT = {
							any_in_list = {
								list = destinations_list
								is_capital_barony = no
								county = scope:county_temp
							}
						}
					}
					alternative_limit = { always = yes }
					max = {
						value = laamp_base_2011_desired_surveyable_holdings_per_tier_value
						subtract = "list_size(destinations_list)"
					}
					check_range_bounds = no
					add_to_list = destinations_list
				}
			}
			# Cool, now let's process how many destinations we've got.
			ordered_in_list = {
				list = destinations_list
				order_by = {
					title_province = { value = "squared_distance(root.location)" }
					multiply = -1
				}
				max = laamp_base_2011_desired_surveyable_holdings_per_tier_value
				check_range_bounds = no
				if = {
					limit = {
						NOT = { exists = scope:destination_1 }
					}
					save_scope_as = destination_1
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							exists = scope:destination_2
						}
					}
					save_scope_as = destination_2
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							exists = scope:destination_3
						}
					}
					save_scope_as = destination_3
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							exists = scope:destination_4
						}
					}
					save_scope_as = destination_4
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							exists = scope:destination_5
						}
					}
					save_scope_as = destination_5
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							exists = scope:destination_6
						}
					}
					save_scope_as = destination_6
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							this = scope:destination_6
							exists = scope:destination_7
						}
					}
					save_scope_as = destination_7
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							this = scope:destination_6
							this = scope:destination_7
							exists = scope:destination_8
						}
					}
					save_scope_as = destination_8
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							this = scope:destination_6
							this = scope:destination_7
							this = scope:destination_8
							exists = scope:destination_9
						}
					}
					save_scope_as = destination_9
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							this = scope:destination_6
							this = scope:destination_7
							this = scope:destination_8
							this = scope:destination_9
							exists = scope:destination_10
						}
					}
					save_scope_as = destination_10
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							this = scope:destination_6
							this = scope:destination_7
							this = scope:destination_8
							this = scope:destination_9
							this = scope:destination_10
							exists = scope:destination_11
						}
					}
					save_scope_as = destination_11
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							this = scope:destination_6
							this = scope:destination_7
							this = scope:destination_8
							this = scope:destination_9
							this = scope:destination_10
							this = scope:destination_11
							exists = scope:destination_12
						}
					}
					save_scope_as = destination_12
				}
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.2014.a

		custom_tooltip = travel.stationary_domicile.tt
		laamp_base_contract_schemes_2014_organise_travel_effect = {
			DOMICILE = no
			RETURN = yes
			EVENT_FIRE = all_but_last
		}
		custom_tooltip = laamp_base_contract_schemes.2014.tt.explanation

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.2014.b

		custom_tooltip = travel.mobile_domicile.tt
		laamp_base_contract_schemes_2014_organise_travel_effect = {
			DOMICILE = yes
			RETURN = no
			EVENT_FIRE = all
		}
		custom_tooltip = laamp_base_contract_schemes.2014.tt.explanation

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.2015 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_2011 }
			save_scope_as = task_contract
		}
		send_interface_message = {
			title = contract_invalidated_title
			type = stewardship_contract_scheme_invalidated_message
			desc = contract_invalidated_desc
			right_icon = scope:task_contract.task_contract_employer
			scope:task_contract = { complete_task_contract = failure_standard }
		}
	}
}

##################################################
# Help construct a building (setup)
# by Ewan Cowhig Croft
# 2021 - 2030
##################################################

#	Intro event.
laamp_base_contract_schemes.2021 = {
	type = character_event
	title = laamp_base_contract_schemes.2021.t
	desc = laamp_base_contract_schemes.2021.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	override_background = { reference = alley_day }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.2021.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_draughtsman
			add_agent_slot = agent_draughtsman
			add_agent_slot = agent_bailiff
			# Speed.
			add_agent_slot = agent_planner
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.2021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_draughtsman
			add_agent_slot = agent_draughtsman
			add_agent_slot = agent_bailiff
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_planner
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.2021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_draughtsman
			# Speed.
			add_agent_slot = agent_planner
			add_agent_slot = agent_planner
			add_agent_slot = agent_supplier
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.2022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.2022.t
	desc = laamp_base_contract_schemes.2022.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = ecstasy
	}
	override_background = { reference = alley_day }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		hidden_effect = {
			scope:employer.capital_province = {
				add_random_building_variable_effect = yes
				add_random_building_construct_effect = yes
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2022.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.2023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.2023.t
	desc = laamp_base_contract_schemes.2023.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = alley_day }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_2021_failure_employer_modifier
						years = 20
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2023.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Settle an administrative boundary dispute (setup)
# by Ewan Cowhig Croft
# 2031 - 2040
##################################################

#	Intro event.
laamp_base_contract_schemes.2031 = {
	type = character_event
	title = laamp_base_contract_schemes.2031.t
	desc = laamp_base_contract_schemes.2031.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:employer
		animation = boredom
	}
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.2031.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_draughtsman
			add_agent_slot = agent_scribe
			# Speed.
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.2031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			add_agent_slot = agent_draughtsman
			add_agent_slot = agent_scribe
			add_agent_slot = agent_bodyguard
			# Speed.
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.2031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bookkeeper
			# Speed.
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.2032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.2032.t
	desc = laamp_base_contract_schemes.2032.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_2031_success_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.2033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.2033.t
	desc = laamp_base_contract_schemes.2033.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = disgust
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_2031_failure_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

#	Roll our first event.
laamp_base_contract_schemes.2035 = {
	hidden = yes

	immediate = {
		random_list = {
			100 = {
				trigger = {
					scope:employer.capital_province = {
						# Nowhere that's largely featureless can quibble over landmarks.
						NOT = { terrain = desert }
					}
				}
				trigger_event = laamp_base_contract_schemes.2661
			}
			100 = {
				# Not appropriate for tribals to argue over walls.
				trigger = {
					NOR = {
						scope:employer = { government_has_flag = government_is_tribal }
						scope:employer = { government_has_flag = government_is_nomadic }
					}
				}
				trigger_event = laamp_base_contract_schemes.2666
			}
			100 = {
				# Not appropriate for tribals to argue over detailed taxes.
				trigger = {
					NOR = {
						scope:employer = { government_has_flag = government_is_tribal }
						scope:employer = { government_has_flag = government_is_nomadic }
					}
				}
				trigger_event = laamp_base_contract_schemes.2671
			}
			100 = { trigger_event = laamp_base_contract_schemes.2676 }
			100 = {
				trigger = {
					scope:employer.capital_province = {
						# Nowhere that's sensibly lacking in good pasture lands — arguably this'd make such even _more_ valuable, and these places do exist, but we rule such out for verisimilitude.
						NOR = {
							terrain = desert
							terrain = desert_mountains
						}
					}
				}
				trigger_event = laamp_base_contract_schemes.2681
			}
		}
	}
}

##################################################
# Collect fake taxes (setup)
# by Ewan Cowhig Croft
# 2041 - 2050
##################################################

#	Intro event.
laamp_base_contract_schemes.2041 = {
	type = character_event
	title = laamp_base_contract_schemes.2041.t
	desc = laamp_base_contract_schemes.2041.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:employer
		animation = personality_honorable
	}
	override_background = { reference = wilderness }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.2041.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bailiff
			add_agent_slot = agent_thug
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.2041.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bailiff
			add_agent_slot = agent_thug
			add_agent_slot = agent_thug
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.2041.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_herald
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.2042 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.2042.t
	desc = laamp_base_contract_schemes.2042.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_prestige = major_prestige_loss
			add_character_modifier = {
				modifier = laamp_base_2041_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2042.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.2043 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.2043.t
	desc = laamp_base_contract_schemes.2043.desc
	theme = stewardship
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = medium_prestige_gain
			add_character_modifier = {
				modifier = laamp_base_2041_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.2043.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_2044_organise_travel_6_destinations_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		destination = scope:destination_4.title_province
		destination = scope:destination_5.title_province
		destination = scope:destination_6.title_province
		on_arrival_event = laamp_base_contract_schemes.2781
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.2045
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_2044_organise_travel_5_destinations_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		destination = scope:destination_4.title_province
		destination = scope:destination_5.title_province
		on_arrival_event = laamp_base_contract_schemes.2781
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.2045
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_2044_organise_travel_4_destinations_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		destination = scope:destination_4.title_province
		on_arrival_event = laamp_base_contract_schemes.2781
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.2045
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_2044_organise_travel_3_destinations_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		on_arrival_event = laamp_base_contract_schemes.2781
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.2045
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.2044 = {
	type = character_event
	title = laamp_base_contract_schemes.2044.t
	desc = laamp_base_contract_schemes.2044.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = disbelief
	}
	override_background = { reference = wilderness }

	immediate = {
		scope:employer = {
			# First, sort out valid counties.
			ordered_sub_realm_county = {
				limit = {
					NOT = { this = scope:employer.capital_county }
				}
				order_by = development_level
				max = laamp_base_2041_num_counties_to_rob_sans_capital_value
				check_range_bounds = no
				add_to_list = preferable_counties_list
			}
			# Then, we organise them for the route.
			ordered_in_list = {
				list = preferable_counties_list
				order_by = {
					title_province = { value = "squared_distance(root.location)" }
					multiply = -1
				}
				max = "list_size(preferable_counties_list)"
				check_range_bounds = no
				if = {
					limit = {
						NOT = { exists = scope:destination_1 }
					}
					save_scope_as = destination_1
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							exists = scope:destination_2
						}
					}
					save_scope_as = destination_2
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							exists = scope:destination_3
						}
					}
					save_scope_as = destination_3
				}
				else_if = {
					limit = {
						"list_size(preferable_counties_list)" >= 4
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							exists = scope:destination_4
						}
					}
					save_scope_as = destination_4
				}
				else_if = {
					limit = {
						"list_size(preferable_counties_list)" >= 5
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							exists = scope:destination_5
						}
					}
					save_scope_as = destination_5
				}
				else_if = {
					limit = {
						"list_size(preferable_counties_list)" >= 6
						NOT = {
							this = scope:destination_1
							this = scope:destination_2
							this = scope:destination_3
							this = scope:destination_4
							this = scope:destination_5
							exists = scope:destination_6
						}
					}
					save_scope_as = destination_6
				}
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.2044.a

		custom_tooltip = travel.stationary_domicile.tt
		switch = {
			trigger = exists
			scope:destination_6 = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.6_destinations }
			scope:destination_5 = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.5_destinations }
			scope:destination_4 = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.4_destinations }
			fallback = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.3_destinations }
		}
		custom_tooltip = laamp_base_contract_schemes.2044.tt.explanation
		switch = {
			trigger = exists
			scope:destination_6 = {
				laamp_base_contract_schemes_2044_organise_travel_6_destinations_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
			scope:destination_5 = {
				laamp_base_contract_schemes_2044_organise_travel_5_destinations_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
			scope:destination_4 = {
				laamp_base_contract_schemes_2044_organise_travel_4_destinations_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
			fallback = {
				laamp_base_contract_schemes_2044_organise_travel_3_destinations_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.2044.b

		custom_tooltip = travel.mobile_domicile.tt
		switch = {
			trigger = exists
			scope:destination_6 = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.6_destinations }
			scope:destination_5 = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.5_destinations }
			scope:destination_4 = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.4_destinations }
			fallback = { custom_tooltip = laamp_base_contract_schemes.2044.tt.destination_list.3_destinations }
		}
		custom_tooltip = laamp_base_contract_schemes.2044.tt.explanation
		switch = {
			trigger = exists
			scope:destination_6 = {
				laamp_base_contract_schemes_2044_organise_travel_6_destinations_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
			scope:destination_5 = {
				laamp_base_contract_schemes_2044_organise_travel_5_destinations_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
			scope:destination_4 = {
				laamp_base_contract_schemes_2044_organise_travel_4_destinations_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
			fallback = {
				laamp_base_contract_schemes_2044_organise_travel_3_destinations_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.2045 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_2041 }
			save_scope_as = task_contract
		}
		send_interface_message = {
			title = contract_invalidated_title
			type = stewardship_contract_scheme_invalidated_message
			right_icon = scope:task_contract.task_contract_employer
			scope:task_contract = { complete_task_contract = failure_standard }
		}
	}
}

##################################################
# EXTRA — STEWARDSHIP

##################################################
# Collect taxes for a third party
# by Ewan Cowhig Croft
# 2301 - 2420
##################################################

scripted_trigger laamp_base_contract_schemes_2301_would_lie_about_cash_trigger = {
	NOR = {
		# Honest chars never lie.
		has_trait = honest
		# Just characters won't lie unless they're actively deceitful.
		AND = {
			has_trait = just
			NOT = { has_trait = deceitful }
		}
	}
}

scripted_effect laamp_base_contract_schemes_2301_nab_quartermaster_effect = {
	# Clean the quartermaster if they exist (in case they die between events).
	clear_saved_scope = quartermaster
	# Now nab 'em afresh.
	court_position:quartermaster_camp_officer ?= {
		if = {
			limit = {
				is_available_allow_travelling = yes
				location = root.location
			}
			save_scope_as = quartermaster
		}
	}
}

#	Arrival at city event.
laamp_base_contract_schemes.2301 = {
	type = character_event
	title = laamp_base_contract_schemes.2301.t
	window = visit_settlement_window
	desc = {
		desc = laamp_base_contract_schemes.2301.desc.intro
		triggered_desc = {
			trigger = { exists = scope:quartermaster }
			desc = laamp_base_contract_schemes.2301.desc.intro.has_quartermaster
		}
		desc = laamp_base_contract_schemes.2301.desc.midtro
		first_valid = {
			# Honest/good liar.
			triggered_desc = {
				trigger = {
					scope:person_a = {
						OR = {
							has_trait = honest
							intrigue >= very_high_skill_rating
						}
					}
				}
				desc = laamp_base_contract_schemes.2301.desc.liar.honest_or_good
			}
			# Not lying.
			triggered_desc = {
				trigger = { scope:tax_status = flag:no_cash }
				desc = laamp_base_contract_schemes.2301.desc.liar.not_lying
			}
			# Poor liar lying.
			triggered_desc = {
				trigger = {
					scope:person_a.intrigue <= mediocre_skill_rating
					scope:tax_status != flag:no_cash
				}
				desc = laamp_base_contract_schemes.2301.desc.liar.poor_liar_lying
			}
			# Lying.
			desc = laamp_base_contract_schemes.2301.desc.liar.other_liars_lying
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:person_a
		animation = happiness
	}
	lower_left_portrait = scope:person_b
	lower_center_portrait = scope:person_c
	lower_right_portrait = scope:person_d
	override_background = { reference = alley_day }

	immediate = {
		# Ok, let's roll to decide whether we can actually pay tax.
		random_list = {
			# Has the cash.
			100 = {
				trigger = {
					scope:person_a = { laamp_base_contract_schemes_2301_would_lie_about_cash_trigger = yes }
				}
				save_scope_value_as = {
					name = tax_status
					value = flag:has_cash
				}
			}
			# Has some of the cash.
			100 = {
				trigger = {
					scope:person_a = { laamp_base_contract_schemes_2301_would_lie_about_cash_trigger = yes }
				}
				save_scope_value_as = {
					name = tax_status
					value = flag:partial_cash
				}
			}
			# Does not have the cash.
			100 = {
				save_scope_value_as = {
					name = tax_status
					value = flag:no_cash
				}
			}
		}
		# Sort our secondary magnates.
		## If scope:person_a has suitable non-family courtiers, nab those.
		scope:person_a = {
			ordered_courtier = {
				limit = {
					is_available_adult = yes
					location = scope:person_a.primary_title.title_province
					NOR = {
						is_close_or_extended_family_of = scope:person_a
						is_consort_of = scope:person_a
					}
				}
				order_by = stewardship
				check_range_bounds = no
				max = 3
				if = {
					limit = {
						NOT = { exists = scope:person_b }
					}
					save_scope_as = person_b
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:person_b
							exists = scope:person_c
						}
					}
					save_scope_as = person_c
				}
				else_if = {
					limit = {
						NOT = {
							this = scope:person_b
							this = scope:person_c
							exists = scope:person_d
						}
					}
					save_scope_as = person_d
				}
			}
		}
		## Now, if we're missing any of our scopes, create them.
		if = {
			limit = {
				NOT = { exists = scope:person_b }
			}
			create_character = {
				template = merchant_template
				employer = scope:person_a
				culture = scope:person_a.location.culture
				faith = scope:person_a.location.faith
				save_scope_as = person_b
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:person_c }
			}
			create_character = {
				template = merchant_template
				employer = scope:person_a
				culture = scope:person_a.location.culture
				faith = scope:person_a.location.faith
				save_scope_as = person_c
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:person_d }
			}
			create_character = {
				template = merchant_template
				employer = scope:person_a
				culture = scope:person_a.location.culture
				faith = scope:person_a.location.faith
				save_scope_as = person_d
			}
		}
		### Append them to the task contract: if they die too early, we invalidate.
		#### Largely a concern for MP.
		scope:task_contract = {
			set_variable = {
				name = person_b
				value = scope:person_b
			}
			set_variable = {
				name = person_c
				value = scope:person_c
			}
			set_variable = {
				name = person_d
				value = scope:person_d
			}
		}
		# Note that we'll be taking our background cues from scope:person_a.
		scope:person_a = {
			if = {
				limit = {
					is_ruler = no
					exists = court_owner
				}
				court_owner = {
					save_scope_as = bg_override_char
					save_scope_as = background_market_scope
				}
			}
			else = {
				save_scope_as = bg_override_char
				save_scope_as = background_market_scope
			}
			
		}
		# Try to grab our quartermaster.
		laamp_base_contract_schemes_2301_nab_quartermaster_effect = yes
		# Plus, stop us whilst we're here.
		hidden_effect = {
			current_travel_plan = { pause_travel_plan = yes }
		}
	}

	# Investigate scope:person_a.
	option = {
		name = laamp_base_contract_schemes.2301.a

		custom_tooltip = laamp_base_contract_schemes.2301.a.tt
		scope:person_a = { save_scope_as = char_current }

		# No stress here.
		# All options equal, AI chooses at random.
	}
	
	# Investigate scope:person_b.
	option = {
		name = laamp_base_contract_schemes.2301.b

		custom_tooltip = laamp_base_contract_schemes.2301.b.tt
		scope:person_b = { save_scope_as = char_current }

		# No stress here.
		# All options equal, AI chooses at random.
	}
	
	# Investigate scope:person_c.
	option = {
		name = laamp_base_contract_schemes.2301.c

		custom_tooltip = laamp_base_contract_schemes.2301.c.tt
		scope:person_c = { save_scope_as = char_current }

		# No stress here.
		# All options equal, AI chooses at random.
	}
	
	# Investigate scope:person_d.
	option = {
		name = laamp_base_contract_schemes.2301.d

		custom_tooltip = laamp_base_contract_schemes.2301.d.tt
		scope:person_d = { save_scope_as = char_current }

		# No stress here.
		# All options equal, AI chooses at random.
	}

	# Trigger our follow-up.
	after = { trigger_event = laamp_base_contract_schemes.2311 }
}

scripted_effect laamp_base_contract_schemes_2311_duel_success_effect = {
	custom_tooltip = laamp_base_contract_schemes.2311.tt.success_increases_score
	scope:task_contract = {
		increment_variable_effect = {
			VAR = clues_gathered
			VAL = 1
		}
	}
	scope:task_contract = {
		increment_variable_effect = {
			VAR = chars_checked
			VAL = 1
		}
	}
	save_scope_value_as = {
		name = result
		value = flag:success
	}
}

scripted_effect laamp_base_contract_schemes_2311_duel_failure_effect = {
	custom_tooltip = laamp_base_contract_schemes.2311.tt.failure_gives_no_score
	scope:task_contract = {
		increment_variable_effect = {
			VAR = chars_checked
			VAL = 1
		}
	}
	save_scope_value_as = {
		name = result
		value = flag:failure
	}
}

scripted_effect laamp_base_contract_schemes_2311_duel_generic_effect = {
	save_scope_value_as = {
		name = method
		value = flag:$SKILL$
	}
	duel = {
		skill = $SKILL$
		target = scope:char_current
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.2311.$SKILL$.tt.success
			laamp_base_contract_schemes_2311_duel_success_effect = yes
		}
		# Defeat!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.2311.$SKILL$.tt.failure
			laamp_base_contract_schemes_2311_duel_failure_effect = yes
		}
	}
}

#	Investigate someone.
laamp_base_contract_schemes.2311 = {
	type = character_event
	title = laamp_base_contract_schemes.2311.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:business = flag:council_chamber }
				desc = laamp_base_contract_schemes.2311.desc.business.council_chamber
			}
			triggered_desc = {
				trigger = { scope:business = flag:armory }
				desc = laamp_base_contract_schemes.2311.desc.business.armory
			}
			triggered_desc = {
				trigger = { scope:business = flag:temple }
				desc = laamp_base_contract_schemes.2311.desc.business.temple
			}
			triggered_desc = {
				trigger = { scope:business = flag:dungeon }
				desc = laamp_base_contract_schemes.2311.desc.business.dungeon
			}
			triggered_desc = {
				trigger = { scope:business = flag:docks }
				desc = laamp_base_contract_schemes.2311.desc.business.docks
			}
			triggered_desc = {
				trigger = { scope:business = flag:study }
				desc = laamp_base_contract_schemes.2311.desc.business.study
			}
			triggered_desc = {
				trigger = { scope:business = flag:physicians_study }
				desc = laamp_base_contract_schemes.2311.desc.business.physicians_study
			}
			triggered_desc = {
				trigger = { scope:business = flag:tavern }
				desc = laamp_base_contract_schemes.2311.desc.business.tavern
			}
			triggered_desc = {
				trigger = { scope:business = flag:bp1_kitchen_western }
				desc = laamp_base_contract_schemes.2311.desc.business.bp1_kitchen_western
			}
			triggered_desc = {
				trigger = { scope:business = flag:market }
				desc = laamp_base_contract_schemes.2311.desc.business.market
			}
			triggered_desc = {
				trigger = { scope:business = flag:bath_house }
				desc = laamp_base_contract_schemes.2311.desc.business.bath_house
			}
		}
		desc = boilerplate.paragraph
		first_valid = {
			triggered_desc = {
				trigger = { scope:personality = flag:mayor }
				desc = laamp_base_contract_schemes.2311.desc.personality.mayor
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_honor }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_honor
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_zeal }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_zeal
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_greed }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_greed
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_compassion }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_compassion
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_boldness }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_boldness
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_rationality }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_rationality
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_vengefulness }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_vengefulness
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_energy }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_energy
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_sociability }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_sociability
			}
			triggered_desc = {
				trigger = { scope:personality = flag:ai_personality_fallback }
				desc = laamp_base_contract_schemes.2311.desc.personality.ai_personality_fallback
			}
		}
		desc = boilerplate.paragraph
		first_valid = {
			triggered_desc = {
				trigger = { scope:loot = flag:gold }
				desc = laamp_base_contract_schemes.2311.desc.loot.gold
			}
			triggered_desc = {
				trigger = { scope:loot = flag:courtier_opinion }
				desc = laamp_base_contract_schemes.2311.desc.loot.courtier_opinion
			}
			triggered_desc = {
				trigger = { scope:loot = flag:piety }
				desc = laamp_base_contract_schemes.2311.desc.loot.piety
			}
			triggered_desc = {
				trigger = { scope:loot = flag:provisions }
				desc = laamp_base_contract_schemes.2311.desc.loot.provisions
			}
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:char_current
		triggered_animation = {
			trigger = { scope:personality = flag:mayor }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_honor }
			animation = personality_honorable
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_zeal }
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_greed }
			animation = personality_greedy
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_compassion }
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_boldness }
			animation = personality_bold
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_rationality }
			animation = personality_rational
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_vengefulness }
			animation = personality_vengeful
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_energy }
			animation = personality_bold
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_sociability }
			animation = personality_forgiving
		}
		triggered_animation = {
			trigger = { scope:personality = flag:ai_personality_fallback }
			animation = stress
		}
	}
	lower_left_portrait = scope:portrait_1
	lower_center_portrait = scope:portrait_2
	lower_right_portrait = scope:portrait_3
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:business = flag:council_chamber }
			reference = council_chamber
		}
		override_background = {
			trigger = { scope:business = flag:armory }
			reference = armory
		}
		override_background = {
			trigger = { scope:business = flag:temple }
			reference = temple
		}
		override_background = {
			trigger = { scope:business = flag:dungeon }
			reference = dungeon
		}
		override_background = {
			trigger = { scope:business = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:business = flag:study }
			reference = study
		}
		override_background = {
			trigger = { scope:business = flag:physicians_study }
			reference = physicians_study
		}
		override_background = {
			trigger = { scope:business = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:business = flag:bp1_kitchen_western }
			reference = bp1_kitchen_western
		}
		override_background = {
			trigger = { scope:business = flag:market }
			reference = market
		}
		override_background = {
			trigger = { scope:business = flag:bath_house }
			reference = bath_house
		}

	immediate = {
		custom_tooltip = laamp_base_contract_schemes.2311.tt.current_clues
		custom_tooltip = laamp_base_contract_schemes.2311.tt.chars_checked
		# Sort our loot.
		random_list = {
			# Gold (1 in 2).
			200 = {
				save_scope_value_as = {
					name = loot
					value = flag:gold
				}
			}
			# Luxuries for courtiers (1 in 16).
			25 = {
				save_scope_value_as = {
					name = loot
					value = flag:courtier_opinion
				}
			}
			# Piety (3 in 16).
			75 = {
				# Only grab relics if it's relevant to us.
				trigger = {
					faith = {
						faith_hostility_level = {
							target = scope:char_current.faith
							value <= faith_fully_accepted_level
						}
					}
				}
				save_scope_value_as = {
					name = loot
					value = flag:piety
				}
			}
			# Provisions (1 in 4).
			100 = {
				save_scope_value_as = {
					name = loot
					value = flag:provisions
				}
			}
		}
		# And what our secondary skill test will be.
		random_list = {
			# Diplomacy.
			100 = {
				save_scope_value_as = {
					name = secondary_duel
					value = flag:diplomacy
				}
				modifier = {
					add = 200
					scope:char_current = { highest_skill = diplomacy }
				}
			}
			# Intrigue.
			100 = {
				save_scope_value_as = {
					name = secondary_duel
					value = flag:intrigue
				}
				modifier = {
					add = 200
					scope:char_current = { highest_skill = intrigue }
				}
			}
			# Learning.
			100 = {
				save_scope_value_as = {
					name = secondary_duel
					value = flag:learning
				}
				modifier = {
					add = 200
					scope:char_current = { highest_skill = learning }
				}
			}
		}
		# Try to grab our quartermaster.
		laamp_base_contract_schemes_2301_nab_quartermaster_effect = yes
		# Personalise the event.
		## If we're looking at scope:person_a, then we pre-configure this stuff.
		if = {
			limit = { scope:char_current = scope:person_a }
			save_scope_value_as = {
				name = business
				value = flag:council_chamber
			}
			save_scope_value_as = {
				name = personality
				value = flag:mayor
			}
		}
		## Otherwise, we're looking at one of the others and need to roll for it.
		else = {
			# Select a business for them to run.
			random_list = {
				100 = {
					trigger = {
						scope:char_current = {
							NOT = { has_trait = compassionate }
						}
					}
					save_scope_value_as = {
						name = business
						value = flag:armory
					}
					scope:task_contract = { set_variable = had_armory_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_armory_business }
					}
				}
				100 = {
					trigger = {
						scope:char_current = {
							NOT = { has_trait = cynical }
						}
					}
					save_scope_value_as = {
						name = business
						value = flag:temple
					}
					scope:task_contract = { set_variable = had_temple_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_temple_business }
					}
				}
				100 = {
					trigger = {
						scope:char_current = {
							NOT = { has_trait = compassionate }
						}
					}
					save_scope_value_as = {
						name = business
						value = flag:dungeon
					}
					scope:task_contract = { set_variable = had_dungeon_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_dungeon_business }
					}
				}
				100 = {
					trigger = {
						scope:destination_1.title_province = { is_coastal = yes }
					}
					save_scope_value_as = {
						name = business
						value = flag:docks
					}
					scope:task_contract = { set_variable = had_docks_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_docks_business }
					}
				}
				100 = {
					save_scope_value_as = {
						name = business
						value = flag:study
					}
					scope:task_contract = { set_variable = had_study_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_study_business }
					}
				}
				100 = {
					save_scope_value_as = {
						name = business
						value = flag:physicians_study
					}
					scope:task_contract = { set_variable = had_physicians_study_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_physicians_study_business }
					}
				}
				100 = {
					trigger = {
						scope:char_current = {
							NOT = { has_trait = temperate }
						}
					}
					save_scope_value_as = {
						name = business
						value = flag:tavern
					}
					scope:task_contract = { set_variable = had_tavern_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_tavern_business }
					}
				}
				100 = {
					trigger = {
						scope:char_current = {
							NOT = { has_trait = temperate }
						}
					}
					save_scope_value_as = {
						name = business
						value = flag:bp1_kitchen_western
					}
					scope:task_contract = { set_variable = had_bp1_kitchen_western_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_bp1_kitchen_western_business }
					}
				}
				100 = {
					trigger = {
						scope:char_current = {
							NOT = { has_trait = generous }
						}
					}
					save_scope_value_as = {
						name = business
						value = flag:market
					}
					scope:task_contract = { set_variable = had_market_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_market_business }
					}
				}
				100 = {
					save_scope_value_as = {
						name = business
						value = flag:bath_house
					}
					scope:task_contract = { set_variable = had_bath_house_business }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_bath_house_business }
					}
				}
			}
			# And a personality to express.
			random_list = {
				100 = {
					trigger = { ai_honor >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_honor
					}
					modifier = {
						add = ai_honor
						always = yes
					}
				}
				100 = {
					trigger = { ai_zeal >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_zeal
					}
					modifier = {
						add = ai_zeal
						always = yes
					}
				}
				100 = {
					trigger = { ai_greed >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_greed
					}
					modifier = {
						add = ai_greed
						always = yes
					}
				}
				100 = {
					trigger = { ai_compassion >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_compassion
					}
					modifier = {
						add = ai_compassion
						always = yes
					}
				}
				100 = {
					trigger = { ai_boldness >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_boldness
					}
					modifier = {
						add = ai_boldness
						always = yes
					}
				}
				100 = {
					trigger = { ai_rationality >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_rationality
					}
					modifier = {
						add = ai_rationality
						always = yes
					}
				}
				100 = {
					trigger = { ai_vengefulness >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_vengefulness
					}
					modifier = {
						add = ai_vengefulness
						always = yes
					}
				}
				100 = {
					trigger = { ai_energy >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_energy
					}
					modifier = {
						add = ai_energy
						always = yes
					}
				}
				100 = {
					trigger = { ai_sociability >= @laamp_base_contract_schemes_2311_ai_weight_threshold_value }
					save_scope_value_as = {
						name = personality
						value = flag:ai_sociability
					}
					modifier = {
						add = ai_sociability
						always = yes
					}
				}
				100 = {
					trigger = {
						ai_honor < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_zeal < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_greed < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_compassion < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_boldness < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_rationality < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_vengefulness < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_energy < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
						ai_sociability < @laamp_base_contract_schemes_2311_ai_weight_threshold_value
					}
					save_scope_value_as = {
						name = personality
						value = flag:ai_personality_fallback
					}
				}
			}
		}
		## Organise our portraits.
		switch = {
			trigger = scope:char_current
			scope:person_a = {
				scope:person_b = { save_scope_as = portrait_1 }
				scope:person_c = { save_scope_as = portrait_2 }
				scope:person_d = { save_scope_as = portrait_3 }
			}
			scope:person_b = {
				scope:person_a = { save_scope_as = portrait_1 }
				scope:person_c = { save_scope_as = portrait_2 }
				scope:person_d = { save_scope_as = portrait_3 }
			}
			scope:person_c = {
				scope:person_a = { save_scope_as = portrait_1 }
				scope:person_b = { save_scope_as = portrait_2 }
				scope:person_d = { save_scope_as = portrait_3 }
			}
			scope:person_d = {
				scope:person_a = { save_scope_as = portrait_1 }
				scope:person_b = { save_scope_as = portrait_2 }
				scope:person_c = { save_scope_as = portrait_3 }
			}
		}
		# Note that we've seen this character.
		scope:char_current = { add_to_list = investigated_persons_list }
	}

	# Stewardship to investigate.
	option = {
		name = laamp_base_contract_schemes.2311.a

		laamp_base_contract_schemes_2311_duel_generic_effect = { SKILL = stewardship }

		# No stress here.
		ai_chance = {
			base = 1
			# AI will prioritise this if it lines up with their highest skill.
			modifier = {
				add = 100
				highest_skill = stewardship
			}
		}
	}
	
	# Secondary investigate with diplo.
	option = {
		name = laamp_base_contract_schemes.2311.b
		trigger = { scope:secondary_duel = flag:diplomacy }

		laamp_base_contract_schemes_2311_duel_generic_effect = { SKILL = diplomacy }

		# No stress here.
		ai_chance = {
			base = 1
			# AI will prioritise this if it lines up with their highest skill.
			modifier = {
				add = 100
				highest_skill = diplomacy
			}
		}
	}
	
	# Secondary investigate with intrigue.
	option = {
		name = laamp_base_contract_schemes.2311.c
		trigger = { scope:secondary_duel = flag:intrigue }

		laamp_base_contract_schemes_2311_duel_generic_effect = { SKILL = intrigue }

		# No stress here.
		ai_chance = {
			base = 1
			# AI will prioritise this if it lines up with their highest skill.
			modifier = {
				add = 100
				highest_skill = intrigue
			}
		}
	}
	
	# Secondary investigate with learning.
	option = {
		name = laamp_base_contract_schemes.2311.d
		trigger = { scope:secondary_duel = flag:learning }

		laamp_base_contract_schemes_2311_duel_generic_effect = { SKILL = learning }

		# No stress here.
		ai_chance = {
			base = 1
			# AI will prioritise this if it lines up with their highest skill.
			modifier = {
				add = 100
				highest_skill = learning
			}
		}
	}
	
	# Simply take a tithe of their goods.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:loot = flag:gold }
						desc = laamp_base_contract_schemes.2311.e.gold
					}
					triggered_desc = {
						trigger = { scope:loot = flag:courtier_opinion }
						desc = laamp_base_contract_schemes.2311.e.courtier_opinion
					}
					triggered_desc = {
						trigger = { scope:loot = flag:piety }
						desc = laamp_base_contract_schemes.2311.e.piety
					}
					triggered_desc = {
						trigger = { scope:loot = flag:provisions }
						desc = laamp_base_contract_schemes.2311.e.provisions
					}
				}
			}
		}

		save_scope_value_as = {
			name = method
			value = flag:thief
		}
		save_scope_value_as = {
			name = result
			value = flag:ignored
		}
		scope:task_contract = {
			increment_variable_effect = {
				VAR = chars_checked
				VAL = 1
			}
		}
		reverse_add_opinion = {
			target = scope:char_current
			modifier = outraged_opinion
			opinion = -50
		}
		scope:char_current = { add_to_list = robbed_chars_list }
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = trickster
			XP_MAX = gallowsbait_xp_minor_gain
			XP_MIN = gallowsbait_xp_minor_gain
		}
		switch = {
			trigger = scope:loot
			flag:gold = {
				scope:char_current = {
					pay_short_term_gold = {
						target = root
						gold = {
							integer_range = {
								min = minor_gold_laamps_value
								max = medium_gold_laamps_value
							}
						}
					}
				}
			}
			flag:courtier_opinion = {
				every_courtier = {
					limit = { is_available_allow_travelling = yes }
					custom = custom.every_follower
					add_opinion = {
						target = root
						modifier = gift_opinion
						opinion = {
							integer_range = {
								min = 10
								max = 25
							}
						}
					}
				}
			}
			flag:piety = {
				add_piety = {
					integer_range = {
						min = minor_piety_gain
						max = medium_piety_gain
					}
				}
			}
			flag:provisions = {
				domicile = {
					change_provisions = {
						integer_range = {
							min = miniscule_provisions_value
							max = minor_provisions_value
						}
					}
				}
			}
		}

		stress_impact = {
			arbitrary = minor_stress_impact_loss
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Huck quartermaster at the problem.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:quartermaster }
						desc = laamp_base_contract_schemes.2311.f.quartermaster_exists
					}
					desc = laamp_base_contract_schemes.2311.f.quartermaster_dnae_exist
				}
			}
		}
		trigger = { employs_court_position = quartermaster_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_quartermaster

		save_scope_value_as = {
			name = method
			value = flag:quartermaster
		}
		scope:quartermaster ?= {
			stress_impact = {
				base = medium_stress_gain
				greedy = minor_stress_impact_loss
				diligent = minor_stress_impact_loss
				generous = minor_stress_impact_gain
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:quartermaster }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					laamp_base_contract_schemes_2311_duel_success_effect = yes
					# Raw aptitude.
					modifier = {
						add = {
							scope:quartermaster ?= { add = "aptitude(quartermaster_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					laamp_base_contract_schemes_2311_duel_failure_effect = yes
					# Raw aptitude.
					modifier = {
						add = {
							scope:quartermaster ?= { add = "aptitude(quartermaster_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:quartermaster = { add = "aptitude(quartermaster_camp_officer)" }
					multiply = 20
				}
				exists = scope:quartermaster
			}
		}
	}

	# Trigger our follow-up.
	after = { trigger_event = laamp_base_contract_schemes.2312 }
}

#	Investigation results.
laamp_base_contract_schemes.2312 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:result = flag:success }
				desc = laamp_base_contract_schemes.2312.t.success
			}
			triggered_desc = {
				trigger = { scope:result = flag:failure }
				desc = laamp_base_contract_schemes.2312.t.failure
			}
			triggered_desc = {
				trigger = { scope:result = flag:ignored }
				desc = laamp_base_contract_schemes.2312.t.ignored
			}
		}
	}
	window = visit_settlement_window
	desc = {
		# Method fluff.
		first_valid = {
			triggered_desc = {
				trigger = { scope:method = flag:stewardship }
				desc = laamp_base_contract_schemes.2312.desc.method.stewardship
			}
			triggered_desc = {
				trigger = { scope:method = flag:diplomacy }
				desc = laamp_base_contract_schemes.2312.desc.method.diplomacy
			}
			triggered_desc = {
				trigger = { scope:method = flag:intrigue }
				desc = laamp_base_contract_schemes.2312.desc.method.intrigue
			}
			triggered_desc = {
				trigger = { scope:method = flag:learning }
				desc = laamp_base_contract_schemes.2312.desc.method.learning
			}
			triggered_desc = {
				trigger = { scope:method = flag:quartermaster }
				desc = laamp_base_contract_schemes.2312.desc.method.quartermaster
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:thief
					scope:loot = flag:gold
				}
				desc = laamp_base_contract_schemes.2312.desc.method.thief.gold
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:thief
					scope:loot = flag:courtier_opinion
				}
				desc = laamp_base_contract_schemes.2312.desc.method.thief.courtier_opinion
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:thief
					scope:loot = flag:piety
				}
				desc = laamp_base_contract_schemes.2312.desc.method.thief.piety
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:thief
					scope:loot = flag:provisions
				}
				desc = laamp_base_contract_schemes.2312.desc.method.thief.provisions
			}
		}
		desc = boilerplate.paragraph
		# Result.
		first_valid = {
			triggered_desc = {
				trigger = { scope:result = flag:success }
				desc = laamp_base_contract_schemes.2312.desc.result.success
			}
			triggered_desc = {
				trigger = { scope:result = flag:failure }
				desc = laamp_base_contract_schemes.2312.desc.result.failure
			}
			triggered_desc = {
				trigger = { scope:result = flag:ignored }
				desc = laamp_base_contract_schemes.2312.desc.result.ignored
			}
		}
		desc = boilerplate.paragraph
		# Result.
		first_valid = {
			triggered_desc = {
				trigger = { "list_size(investigated_persons_list)" >= 4 }
				desc = laamp_base_contract_schemes.2312.desc.result.outro.all_done
			}
			triggered_desc = {
				trigger = { scope:result = flag:success }
				desc = laamp_base_contract_schemes.2312.desc.result.outro.success
			}
			triggered_desc = {
				trigger = { scope:result = flag:failure }
				desc = laamp_base_contract_schemes.2312.desc.result.outro.failure
			}
			triggered_desc = {
				trigger = { scope:result = flag:ignored }
				desc = laamp_base_contract_schemes.2312.desc.result.outro.ignored
			}
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:result = flag:success }
			animation = debating
		}
		triggered_animation = {
			trigger = { scope:result = flag:failure }
			animation = stress
		}
		triggered_animation = {
			trigger = { scope:result = flag:ignored }
			animation = steward
		}
	}
	right_portrait = {
		character = scope:char_current
		triggered_animation = {
			trigger = { scope:result = flag:success }
			animation = worry
		}
		triggered_animation = {
			trigger = { scope:result = flag:failure }
			animation = dismissal
		}
		triggered_animation = {
			trigger = { scope:result = flag:ignored }
			animation = anger
		}
	}
	lower_left_portrait = scope:portrait_1
	lower_center_portrait = scope:portrait_2
	lower_right_portrait = scope:portrait_3
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:business = flag:council_chamber }
			reference = council_chamber
		}
		override_background = {
			trigger = { scope:business = flag:armory }
			reference = armory
		}
		override_background = {
			trigger = { scope:business = flag:temple }
			reference = temple
		}
		override_background = {
			trigger = { scope:business = flag:dungeon }
			reference = dungeon
		}
		override_background = {
			trigger = { scope:business = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:business = flag:study }
			reference = study
		}
		override_background = {
			trigger = { scope:business = flag:physicians_study }
			reference = physicians_study
		}
		override_background = {
			trigger = { scope:business = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:business = flag:bp1_kitchen_western }
			reference = bp1_kitchen_western
		}
		override_background = {
			trigger = { scope:business = flag:market }
			reference = market
		}
		override_background = {
			trigger = { scope:business = flag:bath_house }
			reference = bath_house
		}

	immediate = {
		custom_tooltip = laamp_base_contract_schemes.2311.tt.current_clues
		custom_tooltip = laamp_base_contract_schemes.2311.tt.chars_checked
		# Try to grab our quartermaster.
		laamp_base_contract_schemes_2301_nab_quartermaster_effect = yes
	}

	# Investigate scope:person_a next.
	option = {
		name = laamp_base_contract_schemes.2312.a
		trigger = {
			NOT = {
				scope:person_a = { is_in_list = investigated_persons_list }
			}
		}

		custom_tooltip = laamp_base_contract_schemes.2312.tt.boilerplate.continue_investigation
		scope:person_a = { save_scope_as = char_current }
		trigger_event = laamp_base_contract_schemes.2311

		# No stress here.
		ai_chance = {
			# Select a new target we haven't investigated yet at random.
			base = 1000
		}
	}
	
	# Investigate scope:person_b next.
	option = {
		name = laamp_base_contract_schemes.2312.b
		trigger = {
			NOT = {
				scope:person_b = { is_in_list = investigated_persons_list }
			}
		}

		custom_tooltip = laamp_base_contract_schemes.2312.tt.boilerplate.continue_investigation
		scope:person_b = { save_scope_as = char_current }
		trigger_event = laamp_base_contract_schemes.2311

		# No stress here.
		ai_chance = {
			# Select a new target we haven't investigated yet at random.
			base = 1000
		}
	}
	
	# Investigate scope:person_c next.
	option = {
		name = laamp_base_contract_schemes.2312.c
		trigger = {
			NOT = {
				scope:person_c = { is_in_list = investigated_persons_list }
			}
		}

		custom_tooltip = laamp_base_contract_schemes.2312.tt.boilerplate.continue_investigation
		scope:person_c = { save_scope_as = char_current }
		trigger_event = laamp_base_contract_schemes.2311

		# No stress here.
		ai_chance = {
			# Select a new target we haven't investigated yet at random.
			base = 1000
		}
	}
	
	# Investigate scope:person_d next.
	option = {
		name = laamp_base_contract_schemes.2312.d
		trigger = {
			NOT = {
				scope:person_d = { is_in_list = investigated_persons_list }
			}
		}

		custom_tooltip = laamp_base_contract_schemes.2312.tt.boilerplate.continue_investigation
		scope:person_d = { save_scope_as = char_current }
		trigger_event = laamp_base_contract_schemes.2311

		# No stress here.
		ai_chance = {
			# Select a new target we haven't investigated yet at random.
			base = 1000
		}
	}
	
	# Make your declaration.
	option = {
		name = laamp_base_contract_schemes.2312.e

		custom_tooltip = laamp_base_contract_schemes.2312.tt.boilerplate.end_investigation
		trigger_event = laamp_base_contract_schemes.2321

		# No stress here.
		# AI always does all investigations first & takes this as a fallback.}
	}
}

#	Make declaration.
laamp_base_contract_schemes.2321 = {
	type = character_event
	title = laamp_base_contract_schemes.2321.t
	window = visit_settlement_window
	desc = {
		desc = laamp_base_contract_schemes.2321.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:tax_status = flag:has_cash }
				desc = laamp_base_contract_schemes.2321.desc.tax_status.has_cash
			}
			triggered_desc = {
				trigger = { scope:tax_status = flag:partial_cash }
				desc = laamp_base_contract_schemes.2321.desc.tax_status.partial_cash
			}
			triggered_desc = {
				trigger = { scope:tax_status = flag:no_cash }
				desc = laamp_base_contract_schemes.2321.desc.tax_status.no_cash
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { scope:task_contract.var:clues_gathered >= 4 }
				desc = laamp_base_contract_schemes.2321.desc.clues_gathered.four
			}
			triggered_desc = {
				trigger = { scope:task_contract.var:clues_gathered >= 2 }
				desc = laamp_base_contract_schemes.2321.desc.clues_gathered.two_to_three
			}
			desc = laamp_base_contract_schemes.2321.desc.clues_gathered.one_or_less
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:person_a
		animation = worry
	}
	lower_left_portrait = scope:person_b
	lower_center_portrait = scope:person_c
	lower_right_portrait = scope:person_d
	override_background = { reference = council_chamber }

	immediate = {
		# Right, what's our score?
		custom_tooltip = laamp_base_contract_schemes.2311.tt.current_clues
		custom_tooltip = laamp_base_contract_schemes.2311.tt.chars_checked
		# And what does that mean?
		## Max clues — exceptional within reach.
		if = {
			limit = { scope:task_contract.var:clues_gathered >= 4 }
			custom_tooltip = laamp_base_contract_schemes.2321.tt.clue_total.exceptional_achievable
		}
		## 2-3 clues — normal within reach.
		if = {
			limit = { scope:task_contract.var:clues_gathered >= 2 }
			custom_tooltip = laamp_base_contract_schemes.2321.tt.clue_total.normal_achievable
		}
		## 1 clue — failure possible if they're forced.
		else = {
			custom_tooltip = laamp_base_contract_schemes.2321.tt.clue_total.failure_possible
		}
	}

	# You shall pay.
	option = {
		name = laamp_base_contract_schemes.2321.a

		custom_tooltip = laamp_base_contract_schemes.2321.a.tt
		show_as_tooltip = {
			scope:task_contract = {
				if = {
					limit = { var:clues_gathered >= 4 }
					scope:task_contract = { complete_task_contract = success_critical }
				}
				else = {
					random_list = {
						100 = {
							show_chance = no
							desc = laamp_base_contract_schemes.2321.a.tt.success_standard
							complete_task_contract = success_standard
						}
						100 = {
							show_chance = no
							desc = laamp_base_contract_schemes.2321.a.tt.success_qualified
							complete_task_contract = success_qualified_insufficient_evidence
						}
						100 = {
							show_chance = no
							desc = laamp_base_contract_schemes.2321.a.tt.failure_standard
							complete_task_contract = failure_standard
						}
					}
				}
			}
		}
		trigger_event = laamp_base_contract_schemes.2322

		stress_impact = {
			callous = minor_stress_impact_loss
			just = minor_stress_impact_loss
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			# If we've got 2+ clues, chance this.
			modifier = {
				add = 200
				scope:task_contract.var:clues_gathered >= 2
			}
		}
	}
	
	# You shall pay half.
	option = {
		name = laamp_base_contract_schemes.2321.b

		custom_tooltip = laamp_base_contract_schemes.2321.b.tt
		show_as_tooltip = {
			scope:task_contract = { complete_task_contract = success_qualified_reduced_tax }
		}
		trigger_event = laamp_base_contract_schemes.2323

		stress_impact = {
			callous = miniscule_stress_impact_loss
			just = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			# If we have less than 2 clues, play it safe.
			modifier = {
				add = 200
				scope:task_contract.var:clues_gathered < 2
			}
		}
	}
	
	# You are clearly too poor.
	option = {
		name = laamp_base_contract_schemes.2321.c

		custom_tooltip = laamp_base_contract_schemes.2321.c.tt
		show_as_tooltip = {
			scope:task_contract = { complete_task_contract = failure_took_wrong_side }
		}
		trigger_event = laamp_base_contract_schemes.2324

		stress_impact = {
			generous = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_compassion = 2 }
		}
	}
}

scripted_effect laamp_base_contract_schemes_2322_apply_local_opinions_effect = {
	reverse_add_opinion = {
		target = scope:person_a
		modifier = angry_opinion
		opinion = $OPINION$
	}
	reverse_add_opinion = {
		target = scope:person_b
		modifier = angry_opinion
		opinion = $OPINION$
	}
	reverse_add_opinion = {
		target = scope:person_c
		modifier = angry_opinion
		opinion = $OPINION$
	}
	reverse_add_opinion = {
		target = scope:person_d
		modifier = angry_opinion
		opinion = $OPINION$
	}
}

#	Conclusion: made to pay.
laamp_base_contract_schemes.2322 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:total_result = flag:success_critical }
				desc = laamp_base_contract_schemes.2322.t.success_critical
			}
			triggered_desc = {
				trigger = { scope:total_result = flag:success_standard }
				desc = laamp_base_contract_schemes.2322.t.success_standard
			}
			triggered_desc = {
				trigger = { scope:total_result = flag:success_qualified_insufficient_evidence }
				desc = laamp_base_contract_schemes.2322.t.success_qualified_insufficient_evidence
			}
			triggered_desc = {
				trigger = { scope:total_result = flag:violence }
				desc = laamp_base_contract_schemes.2322.t.violence
			}
		}
	}
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:total_result = flag:violence }
				desc = laamp_base_contract_schemes.2322.desc.violence
			}
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:total_result = flag:success_critical }
						desc = laamp_base_contract_schemes.2322.desc.success_critical
					}
					triggered_desc = {
						trigger = { scope:total_result = flag:success_standard }
						desc = laamp_base_contract_schemes.2322.desc.success_standard
					}
					triggered_desc = {
						trigger = { scope:total_result = flag:success_qualified_insufficient_evidence }
						desc = laamp_base_contract_schemes.2322.desc.success_qualified_insufficient_evidence
					}
				}
				desc = boilerplate.paragraph
				first_valid = {
					triggered_desc = {
						trigger = { scope:tax_status = flag:has_cash }
						desc = laamp_base_contract_schemes.2322.desc.tax_status.has_cash
					}
					triggered_desc = {
						trigger = { scope:tax_status = flag:partial_cash }
						desc = laamp_base_contract_schemes.2322.desc.tax_status.partial_cash
					}
					triggered_desc = {
						trigger = { scope:tax_status = flag:no_cash }
						desc = laamp_base_contract_schemes.2322.desc.tax_status.no_cash
					}
				}
			}
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:total_result = flag:violence }
			animation = fear
		}
		animation = steward
	}
	right_portrait = {
		character = scope:person_a
		triggered_animation = {
			trigger = { scope:total_result = flag:violence }
			animation = anger
		}
		animation = disgust
	}
	lower_left_portrait = scope:person_b
	lower_center_portrait = scope:person_c
	lower_right_portrait = scope:person_d
	override_background = { reference = council_chamber }

	immediate = {
		# Alrighty, let's process our results.
		## We got a crit success.
		if = {
			limit = { scope:task_contract.var:clues_gathered >= 4 }
			save_scope_value_as = {
				name = total_result
				value = flag:success_critical
			}
			scope:task_contract = { complete_task_contract = success_critical }
		}
		## We got a standard success.
		else_if = {
			limit = { scope:task_contract.var:clues_gathered >= 2 }
			save_scope_value_as = {
				name = total_result
				value = flag:success_standard
			}
			scope:task_contract = { complete_task_contract = success_standard }
		}
		## Otherwise, we're gonna need to roll to see if the locals get violent.
		else = {
			# A calm or craven scope:person_a will never do this.
			if = {
				limit = {
					scope:person_a = {
						OR = {
							has_trait = calm
							has_trait = craven
						}
					}
				}
				save_scope_value_as = {
					name = total_result
					value = flag:success_qualified_insufficient_evidence
				}
				scope:task_contract = { complete_task_contract = success_qualified_insufficient_evidence }
			}
			# A wrathful scope:person_a will _only_ do this.
			else_if = {
				limit = {
					scope:person_a = { has_trait = wrathful }
				}
				save_scope_value_as = {
					name = total_result
					value = flag:violence
				}
			}
			# Everyone else rolls the highest of their boldness or vengeance, min 20%.
			else = {
				random = {
					chance = {
						if = {
							limit = { scope:person_a.ai_vengefulness >= scope:person_a.ai_boldness }
							add = scope:person_a.ai_vengefulness
						}
						else = { add = scope:person_a.ai_boldness }
						min = 20
						# Plus weight this up a bit for every person we robbed.
						every_in_list = {
							list = robbed_chars_list
							add = 10
						}
					}
					save_scope_value_as = {
						name = total_result
						value = flag:violence
					}
					# Work out who the boldest/most vengeful is amongst our B cast (since they're gonna die).
					scope:person_b = { add_to_list = sod_the_king_list }
					scope:person_c = { add_to_list = sod_the_king_list }
					scope:person_d = { add_to_list = sod_the_king_list }
					ordered_in_list = {
						list = sod_the_king_list
						order_by = {
							value = ai_vengefulness
							add = {
								value = ai_boldness
								multiply = 0.5
								min = 0
							}
						}
						save_scope_as = aggressor
					}
				}
				# If our roll produced no scope, then that means we've opted for peace.
				if = {
					limit = {
						NOT = { exists = scope:total_result }
					}
					save_scope_value_as = {
						name = total_result
						value = flag:success_qualified_insufficient_evidence
					}
					scope:task_contract = { complete_task_contract = success_qualified_insufficient_evidence }
				}
			}
		}
	}

	# Critical success!
	option = {
		name = laamp_base_contract_schemes.2322.a
		trigger = { scope:total_result = flag:success_critical }

		# We're just putting an effect here so the tooltip doesn't look empty, the actual effect lives in the immediate.
		laamp_base_contract_schemes_2322_apply_local_opinions_effect = { OPINION = -15 }

		# No stress here.
		# Only option if it appears.
	}
	
	# Success!
	option = {
		name = laamp_base_contract_schemes.2322.b
		trigger = { scope:total_result = flag:success_standard }

		# We're just putting an effect here so the tooltip doesn't look empty, the actual effect lives in the immediate.
		laamp_base_contract_schemes_2322_apply_local_opinions_effect = { OPINION = -30 }

		# No stress here.
		# Only option if it appears.
	}
	
	# Partial success!
	option = {
		name = laamp_base_contract_schemes.2322.c
		trigger = { scope:total_result = flag:success_qualified_insufficient_evidence }

		# We're just putting an effect here so the tooltip doesn't look empty, the actual effect lives in the immediate.
		laamp_base_contract_schemes_2322_apply_local_opinions_effect = { OPINION = -45 }

		# No stress here.
		# Only option if it appears.
	}
	
	# Chance a military solution for a partial success or a critical failure.
	option = {
		name = laamp_base_contract_schemes.2322.d
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.2322.d.tt.need_troops
				current_military_strength >= 500
			}
		}
		show_as_unavailable = { scope:total_result = flag:violence }

		duel = {
			skill = martial
			value = high_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2322.d.tt.success
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = success_qualified_beaten_down }
				}
				save_scope_value_as = {
					name = violence_result
					value = flag:quelled
				}
				trigger_event = laamp_base_contract_schemes.2332
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2322.d.tt.failure
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = failure_critical }
				}
				save_scope_value_as = {
					name = violence_result
					value = flag:massacre
				}
				trigger_event = laamp_base_contract_schemes.2332
			}
		}

		stress_impact = {
				brave = miniscule_stress_impact_loss
				wrathful = miniscule_stress_impact_loss
				calm = minor_stress_impact_gain
				craven = minor_stress_impact_gain
			}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_vengefulness = -1 }
			ai_value_modifier = { ai_boldness = -2 }
		}
	}
	
	# Take a simple failure.
	option = {
		name = laamp_base_contract_schemes.2322.e
		trigger = { scope:total_result = flag:violence }

		scope:task_contract = { complete_task_contract = failure_standard }

		# Only apply stress if we could've chosen a braver route.
		if = {
			limit = { current_military_strength < 500 }
			stress_impact = {
				craven = miniscule_stress_impact_loss
				calm = miniscule_stress_impact_loss
				wrathful = minor_stress_impact_gain
				brave = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 2 }
			ai_value_modifier = { ai_vengefulness = 1 }
		}
	}

	after = {
		# And send our laamp off — if appropriate.
		hidden_effect = {
			if = {
				limit = {
					NOT = { exists = scope:violence_result }
				}
				current_travel_plan = { resume_travel_plan = yes }
				return_home = yes
			}
		}
	}
}

#	Conclusion: allowed to pay half.
laamp_base_contract_schemes.2323 = {
	type = character_event
	title = laamp_base_contract_schemes.2323.t
	window = visit_settlement_window
	desc = laamp_base_contract_schemes.2323.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:person_a
		animation = disapproval
	}
	lower_left_portrait = scope:person_b
	lower_center_portrait = scope:person_c
	lower_right_portrait = scope:person_d
	override_background = { reference = council_chamber }

	immediate = {
		scope:task_contract = { complete_task_contract = success_qualified_reduced_tax }
	}

	# Take a partial success.
	option = {
		name = laamp_base_contract_schemes.2323.a

		duel = {
			skill = diplomacy
			target = scope:person_a
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2323.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.2323.a.tt.success
					left_icon = scope:person_a
					add_contact = scope:person_a
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2323.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.2323.a.tt.failure
					left_icon = scope:person_a
					custom_tooltip = laamp_base_contract_schemes.2323.a.tt.failure.filler
				}
			}
		}
		# And send our laamp off.
		hidden_effect = {
			return_home = yes
		}

		# Neither stress nor AI chance, for t'is the only option.
	}

	# Legitimists: touch me and lose it, riffraff.
	option = {
		name = laamp_base_contract_schemes.2323.b
		trigger = { has_realm_law = camp_purpose_legitimists }
		reason = purpose_legitimists

		add_prestige = medium_prestige_gain
		reverse_add_opinion = {
			target = scope:person_a
			modifier = respect_opinion
			opinion = -50
		}

		# And send our laamp off.
		hidden_effect = {
			return_home = yes
		}

		stress_impact = {
			arrogant = medium_stress_loss
			humble = medium_stress_gain
		}
		# Don't worry about AI chance, we don't mind the AI taking this or not.
	}

	after = {
		hidden_effect = {
			current_travel_plan = { resume_travel_plan = yes }
			return_home = yes
		}
	}
}

scripted_trigger laamp_base_contract_schemes_2324_valid_admirer_trigger = {
	"opinion(root)" >= 75
	OR = {
		sum_of_all_skills_and_prowess_value >= 60
		average_of_all_skills_and_prowess >= 10
		highest_skill_value >= extremely_high_skill_rating
	}
	NOT = { is_in_list = robbed_chars_list }
}

scripted_trigger laamp_base_contract_schemes_2324_receive_second_option_trigger = {
	"list_size(robbed_chars_list)" <= 2
	NOT = { has_claim_on = scope:person_a.primary_title.duchy }
}

#	Conclusion: let off the hook.
laamp_base_contract_schemes.2324 = {
	type = character_event
	title = laamp_base_contract_schemes.2324.t
	window = visit_settlement_window
	desc = {
		desc = laamp_base_contract_schemes.2324.desc
		triggered_desc = {
			trigger = { laamp_base_contract_schemes_2324_receive_second_option_trigger = yes }
			desc = laamp_base_contract_schemes.2324.desc.second_option
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = hero_flex
	}
	right_portrait = {
		character = scope:person_a
		animation = throne_room_cheer_2
	}
	lower_left_portrait = scope:person_b
	lower_center_portrait = scope:person_c
	lower_right_portrait = scope:person_d
	override_background = { reference = council_chamber }

	immediate = {
		scope:task_contract = { complete_task_contract = failure_took_wrong_side }
		# What would we give a claim on?
		scope:person_a.primary_title.duchy = { save_scope_as = claim_duchy }
	}

	# Alt success & take the contacts.
	option = {
		name = laamp_base_contract_schemes.2324.a

		add_contact = scope:person_a
		add_favour_hook_if_possible_simple_effect = { TARGET = scope:person_a }
		add_prestige = minor_prestige_gain

		# Stress only applies if we have multiple options.
		if = {
			limit = { laamp_base_contract_schemes_2324_receive_second_option_trigger = yes }
			stress_impact = {
				just = miniscule_stress_impact_loss
				humble = miniscule_stress_impact_loss
				content = miniscule_stress_impact_loss
				ambitious = minor_stress_impact_gain
				arrogant = minor_stress_impact_gain
				arbitrary = minor_stress_impact_gain
			}
		}
		# The AI should always take this option.
		ai_chance = { base = 1000 }
	}
	
	# Alt success & take the duchy claim.
	option = {
		name = laamp_base_contract_schemes.2324.b
		trigger = { laamp_base_contract_schemes_2324_receive_second_option_trigger = yes }

		add_pressed_claim = scope:claim_duchy
		if = {
			limit = { exists = scope:claim_duchy.holder }
			scope:claim_duchy.holder = {
				add_opinion = {
					target = root
					modifier = outraged_opinion
					opinion = -50
				}
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:employer
				modifier = outraged_opinion
				opinion = -50
			}
		}
		# Set up a potential future rivalry if possible.
		hidden_effect = {
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:employer }
				}
				set_relation_potential_rival = scope:employer
			}
		}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			arbitrary = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		# No AI chance — the AI doesn't know how to make good use of a random duchy claim as a laamp, so we just tell them to play it safe.
	}

	after = {
		# See if we might have an admirer.
		## First, grab our candidates.
		scope:person_b = {
			if = {
				limit = { laamp_base_contract_schemes_2324_valid_admirer_trigger = yes }
				add_to_list = potential_admirers_list
			}
		}
		scope:person_c = {
			if = {
				limit = { laamp_base_contract_schemes_2324_valid_admirer_trigger = yes }
				add_to_list = potential_admirers_list
			}
		}
		scope:person_d = {
			if = {
				limit = { laamp_base_contract_schemes_2324_valid_admirer_trigger = yes }
				add_to_list = potential_admirers_list
			}
		}
		## Then, nab the best fit.
		ordered_in_list = {
			list = potential_admirers_list
			order_by = {
				add = sum_of_all_skills_and_prowess_value
				add = average_of_all_skills_and_prowess
				add = highest_skill_value
			}
			save_scope_as = hopeful
			random = {
				chance = 50
				trigger_event = {
					id = laamp_base_contract_schemes.2331
					years = { 3 6 }
				}
			}
		}
		# And send our laamp off.
		hidden_effect = {
			current_travel_plan = { resume_travel_plan = yes }
			return_home = yes
		}
	}
}

#	Follow-up: impressed secondary char follows you.
laamp_base_contract_schemes.2331 = {
	type = character_event
	title = laamp_base_contract_schemes.2331.t
	desc = laamp_base_contract_schemes.2331.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:hopeful
		animation = admiration
	}
	override_background = { reference = ep3_campfire }

	trigger = {
		is_location_valid_for_travel_event_on_land = yes
		is_landless_adventurer = yes
		scope:hopeful = {
			is_ruler = no
			is_imprisoned = no
			NOR = {
				liege ?= { is_ai = no }
				is_married = yes
			}
		}
	}

	immediate = {
		scope:hopeful = {
			set_location = { location = root.location }
		}
	}

	# I accept.
	option = {
		name = laamp_base_contract_schemes.2331.a
		
		add_courtier = scope:hopeful
		reverse_add_opinion = {
			target = scope:hopeful
			modifier = grateful_opinion
			opinion = 150
		}

		ai_chance = {
			# Free courtier.
			base = 1000
		}
	}
	
	# You'd be a waste of salt.
	option = {
		name = laamp_base_contract_schemes.2331.b
		
		add_prestige = minor_prestige_gain
		hidden_effect = {
			scope:hopeful = { silent_disappearance_effect = yes }
		}

		stress_impact = {
			callous = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		# No AI chance — we always want them to take the courtier.
	}
}

#	Follow-up: outcome of violence.
laamp_base_contract_schemes.2332 = {
	type = character_event
	title = laamp_base_contract_schemes.2332.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:violence_result = flag:quelled }
				desc = laamp_base_contract_schemes.2332.desc.quelled
			}
			desc = laamp_base_contract_schemes.2332.desc.massacre
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = rage
	}
	right_portrait = {
		character = scope:person_a
		animation = fear
	}
	override_background = {
		trigger = { scope:violence_result = flag:quelled }
		reference = alley_night
	}
	override_background = {
		trigger = { scope:violence_result = flag:massacre }
		reference = battlefield
	}

	immediate = {
		if = {
			limit = { scope:violence_result = flag:quelled }
			scope:task_contract = { complete_task_contract = success_qualified_beaten_down }
			# Now that the contract is over, it's safe to kill 'em.
			scope:aggressor = {
				death = {
					death_reason = death_slain_in_riot
					killer = root
				}
			}
		}
		else_if = {
			limit = { scope:violence_result = flag:massacre }
			scope:task_contract = { complete_task_contract = failure_critical }
			# Now that the contract is over, it's safe to kill 'em.
			scope:person_a = {
				death = {
					death_reason = death_slain_in_riot
					killer = root
				}
			}
			scope:person_b = {
				death = {
					death_reason = death_slain_in_riot
					killer = root
				}
			}
			scope:person_c = {
				death = {
					death_reason = death_slain_in_riot
					killer = root
				}
			}
			scope:person_d = {
				death = {
					death_reason = death_slain_in_riot
					killer = root
				}
			}
		}
	}

	# Sometimes needs must.
	option = {
		name = laamp_base_contract_schemes.2332.a
		trigger = { scope:violence_result = flag:quelled }
		
		# We're just putting an effect here so the tooltip doesn't look empty, the actual effect lives in the immediate.
		reverse_add_opinion = {
			target = scope:person_a
			modifier = butcher_opinion
			opinion = -60
		}
		scope:person_b = {
			if = {
				limit = { is_alive = yes }
				add_opinion = {
					target = root
					modifier = butcher_opinion
					opinion = -60
				}
			}
		}
		scope:person_c = {
			if = {
				limit = { is_alive = yes }
				add_opinion = {
					target = root
					modifier = butcher_opinion
					opinion = -60
				}
			}
		}
		scope:person_d = {
			if = {
				limit = { is_alive = yes }
				add_opinion = {
					target = root
					modifier = butcher_opinion
					opinion = -60
				}
			}
		}
		
		# No stress here.
		# No AI chance, one option per result.
	}
	
	# This... this got out of hand...
	option = {
		name = laamp_base_contract_schemes.2332.b
		trigger = {
			scope:violence_result = flag:massacre
			NOR = {
				has_trait = callous
				has_trait = sadistic
			}
		}

		# Effect is in the stress impact.

		stress_impact = {
			base = major_stress_gain
			wrathful = major_stress_impact_loss
			compassionate = major_stress_impact_gain
		}
		# No AI chance, one option per result.
	}
	
	# Callous variant.
	option = {
		name = laamp_base_contract_schemes.2332.c
		trigger = {
			scope:violence_result = flag:massacre
			has_trait = callous
		}

		# Effect is in the stress impact.

		stress_impact = {
			callous = medium_stress_loss
			wrathful = major_stress_impact_loss
		}
		# No AI chance, one option per result.
	}
	
	# Sadistic variant.
	option = {
		name = laamp_base_contract_schemes.2332.d
		trigger = {
			scope:violence_result = flag:massacre
			has_trait = sadistic
		}

		# Effect is in the stress impact.

		stress_impact = {
			sadistic = major_stress_loss
			wrathful = major_stress_impact_loss
		}
		# No AI chance, one option per result.
	}

	after = {
		# And send our laamp off.
		hidden_effect = {
			return_home = yes
		}
	}
}

##################################################
# Perform a census
# by Ewan Cowhig Croft
# 2541 - 2660
############################################

#	Take down local census data.
laamp_base_contract_schemes.2541 = {
	type = character_event
	title = laamp_base_contract_schemes.2541.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:fluff_type = flag:boredom }
				desc = laamp_base_contract_schemes.2541.desc.fluff_type.boredom
			}
			triggered_desc = {
				trigger = { scope:fluff_type = flag:paranoia }
				desc = laamp_base_contract_schemes.2541.desc.fluff_type.paranoia
			}
			triggered_desc = {
				trigger = { scope:fluff_type = flag:happiness }
				desc = laamp_base_contract_schemes.2541.desc.fluff_type.happiness
			}
			triggered_desc = {
				trigger = { scope:fluff_type = flag:disgust }
				desc = laamp_base_contract_schemes.2541.desc.fluff_type.disgust
			}
			triggered_desc = {
				trigger = { scope:fluff_type = flag:admiration }
				desc = laamp_base_contract_schemes.2541.desc.fluff_type.admiration
			}
			triggered_desc = {
				trigger = { scope:fluff_type = flag:worry }
				desc = laamp_base_contract_schemes.2541.desc.fluff_type.worry
			}
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:fluff_type = flag:boredom }
			animation = anger
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:paranoia }
			animation = stress
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:happiness }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:disgust }
			animation = stress
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:admiration }
			animation = happiness
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:worry }
			animation = stress
		}
	}
	right_portrait = {
		character = scope:random_local
		triggered_animation = {
			trigger = { scope:fluff_type = flag:boredom }
			animation = boredom
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:paranoia }
			animation = paranoia
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:happiness }
			animation = happiness
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:disgust }
			animation = dismissal
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:admiration }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:fluff_type = flag:worry }
			animation = worry
		}
		hide_info = yes
	}
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:background = flag:council_chamber }
			reference = council_chamber
		}
		override_background = {
			trigger = { scope:background = flag:temple }
			reference = temple
		}
		override_background = {
			trigger = { scope:background = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:background = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:background = flag:market }
			reference = market
		}
		override_background = {
			trigger = { scope:background = flag:alley_day }
			reference = alley_day
		}

	immediate = {
		# Hold up.
		hidden_effect = {
			current_travel_plan = { pause_travel_plan = yes }
		}
		# Sort out quartermaster.
		## Clean their scope if they exist (in case they die between events).
		clear_saved_scope = officer
		## Now nab 'em afresh.
		court_position:quartermaster_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					location = root.location
				}
				save_scope_as = officer
			}
		}
		# And create a local peasant, if we're not the AI.
		if = {
			limit = { is_ai = no }
			location = {
				create_character = {
					template = merchant_template
					location = root.location
					save_scope_as = random_local
				}
			}
			scope:random_local = {
				if = {
					limit = {
						is_ruler = no
						exists = court_owner
					}
					court_owner = { save_scope_as = bg_override_char }
				}
				else = {
					save_scope_as = bg_override_char
				}
			}
		}
		# Plus randomise our fluff.
		random_list = {
			1 = {
				# Make sure that we don't get the same negative option twice in a row.
				trigger = {
					trigger_if = {
						limit = { exists = scope:fluff_type }
						NOT = { scope:fluff_type = flag:boredom }
					}
				}
				save_scope_value_as = {
					name = fluff_type
					value = flag:boredom
				}
			}
			1 = {
				# Make sure that we don't get the same negative option twice in a row.
				trigger = {
					trigger_if = {
						limit = { exists = scope:fluff_type }
						NOT = { scope:fluff_type = flag:paranoia }
					}
				}
				save_scope_value_as = {
					name = fluff_type
					value = flag:paranoia
				}
			}
			1 = {
				trigger = { location.county.county_opinion >= 0 }
				# Weight this up if they're actually happy (bearing in mind that zero is the default opinion for most counties).
				modifier = {
					add = {
						value = location.county.county_opinion
						multiply = 0.1
						ceiling = yes
					}
					location.county.county_opinion >= 1
				}
				save_scope_value_as = {
					name = fluff_type
					value = flag:happiness
				}
				domicile = { change_provisions = miniscule_provisions_gain }
			}
			1 = {
				# Make sure that we don't get the same negative option twice in a row.
				trigger = {
					trigger_if = {
						limit = { exists = scope:fluff_type }
						NOT = { scope:fluff_type = flag:disgust }
					}
				}
				save_scope_value_as = {
					name = fluff_type
					value = flag:disgust
				}
			}
			1 = {
				trigger = { location.county.county_opinion >= 0 }
				save_scope_value_as = {
					name = fluff_type
					value = flag:admiration
				}
			}
			1 = {
				# Make sure that we don't get the same negative option twice in a row.
				trigger = {
					trigger_if = {
						limit = { exists = scope:fluff_type }
						NOT = { scope:fluff_type = flag:worry }
					}
				}
				save_scope_value_as = {
					name = fluff_type
					value = flag:worry
				}
			}
		}
		# And swap around our background.
		if = {
			limit = { is_ai = no }
			random_list = {
				100 = {
					save_scope_value_as = {
						name = background
						value = flag:council_chamber
					}
					scope:task_contract = { set_variable = had_council_chamber_background }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_council_chamber_background }
					}
				}
				100 = {
					save_scope_value_as = {
						name = background
						value = flag:temple
					}
					scope:task_contract = { set_variable = had_temple_background }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_temple_background }
					}
				}
				100 = {
					trigger = {
						location = { is_coastal = yes }
					}
					save_scope_value_as = {
						name = background
						value = flag:docks
					}
					scope:task_contract = { set_variable = had_docks_background }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_docks_background }
					}
				}
				100 = {
					save_scope_value_as = {
						name = background
						value = flag:tavern
					}
					scope:task_contract = { set_variable = had_tavern_background }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_tavern_background }
					}
				}
				100 = {
					save_scope_value_as = {
						name = background
						value = flag:market
					}
					scope:task_contract = { set_variable = had_market_background }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_market_background }
					}
				}
				100 = {
					save_scope_value_as = {
						name = background
						value = flag:alley_day
					}
					scope:task_contract = { set_variable = had_alley_day_background }
					modifier = {
						add = -99
						scope:task_contract = { has_variable = had_alley_day_background }
					}
				}
			}
		}
		# Grab our location for loc.
		location.barony = { save_scope_as = location }
	}

	# Stewardship challenge.
	option = {
		name = laamp_base_contract_schemes.2541.a
		skill = stewardship

		scope:task_contract = {
			increment_variable_effect = {
				VAR = destinations_processed
				VAL = 1
			}
		}
		duel = {
			skill = stewardship
			value = decent_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = 30
					scope:fluff_type = flag:happiness
				}
				modifier = {
					add = 15
					scope:fluff_type = flag:admiration
				}
				min = 5
				desc = laamp_base_contract_schemes.2541.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.2541.a.tt.success
					custom_tooltip = laamp_base_contract_schemes.2541.a.tt.success.tt
					scope:task_contract = {
						increment_variable_effect = {
							VAR = destinations_processed_legit_success
							VAL = 1
						}
					}
					scope:location.county = {
						if = {
							limit = { county_control < 100 }
							change_county_control = medium_county_control_gain
						}
					}
				}
				if = {
					limit = { scope:fluff_type = flag:happiness }
					custom_tooltip = laamp_base_contract_schemes.2541.a.tt.easier.happiness
				}
				if = {
					limit = { scope:fluff_type = flag:admiration }
					custom_tooltip = laamp_base_contract_schemes.2541.a.tt.easier.easier_admiration
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = -30
					scope:fluff_type = flag:happiness
				}
				modifier = {
					add = -15
					scope:fluff_type = flag:admiration
				}
				min = 5
				desc = laamp_base_contract_schemes.2541.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.2541.a.tt.failure
					custom_tooltip = laamp_base_contract_schemes.2541.a.tt.failure.tt
					scope:task_contract = {
						increment_variable_effect = {
							VAR = destinations_processed_legit_failure
							VAL = 1
						}
					}
				}
			}
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Intrigue auto-win.
	option = {
		name = laamp_base_contract_schemes.2541.b
		trigger = {
			intrigue >= @laamp_base_contract_schemes_2541_intrigue_threshold_value
			NOT = { has_character_flag = laamp_base_contract_schemes_2541_b_on_cooldown }
		}
		skill = intrigue

		custom_tooltip = laamp_base_contract_schemes.2541.b.tt
		scope:task_contract = {
			increment_variable_effect = {
				VAR = destinations_processed_lied_success
				VAL = 1
			}
			increment_variable_effect = {
				VAR = destinations_processed
				VAL = 1
			}
		}
		scope:location.county = {
			if = {
				limit = {
					holder = { is_ai = yes }
				}
				change_county_control = medium_county_control_loss
			}
		}
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = trickster
			XP_MAX = gallowsbait_xp_minor_gain
			XP_MIN = gallowsbait_xp_minor_gain
		}
		# Put this on cool-down for ~3 months so you can't use it every time in short trips.
		add_character_flag = {
			flag = laamp_base_contract_schemes_2541_b_on_cooldown
			months = 3
		}

		stress_impact = {
			deceitful = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			# Take the auto-success — _if_ you're a bit of a prick.
			modifier = {
				add = 10000
				0 >= ai_honor
			}
		}
	}
	
	# Intrigue challenge.
	option = {
		name = laamp_base_contract_schemes.2541.c
		trigger = {
			OR = {
				intrigue <= @laamp_base_contract_schemes_2541_intrigue_threshold_value
				has_character_flag = laamp_base_contract_schemes_2541_b_on_cooldown
			}
		}
		skill = intrigue

		scope:task_contract = {
			increment_variable_effect = {
				VAR = destinations_processed
				VAL = 1
			}
		}
		duel = {
			skill = intrigue
			value = medium_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2541.c.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.2541.c.tt.success
					custom_tooltip = laamp_base_contract_schemes.2541.c.tt.success.tt
					scope:task_contract = {
						increment_variable_effect = {
							VAR = destinations_processed_lied_success
							VAL = 1
						}
					}
					scope:location.county = {
						if = {
							limit = {
								holder = { is_ai = yes }
							}
							change_county_control = medium_county_control_loss
						}
					}
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2541.c.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.2541.c.tt.failure
					custom_tooltip = laamp_base_contract_schemes.2541.c.tt.failure.tt
					scope:task_contract = {
						increment_variable_effect = {
							VAR = destinations_processed_lied_failure
							VAL = 1
						}
					}
				}
			}
		}
		custom_tooltip = laamp_base_contract_schemes.2541.c.tt.explicit_odds_note
		
		stress_impact = {
			deceitful = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Tag in quartermaster.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:officer }
						desc = laamp_base_contract_schemes.2541.d.officer_exists
					}
					desc = laamp_base_contract_schemes.2541.d.officer_unexists
				}
			}
		}
		trigger = { employs_court_position = quartermaster_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_quartermaster

		scope:task_contract = {
			increment_variable_effect = {
				VAR = destinations_processed
				VAL = 1
			}
		}
		scope:officer ?= {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:officer }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					scope:task_contract = {
						increment_variable_effect = {
							VAR = destinations_processed_quartermaster_success
							VAL = 1
						}
					}
					scope:location.county = {
						if = {
							limit = { county_control < 100 }
							change_county_control = medium_county_control_gain
						}
					}
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(quartermaster_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					scope:task_contract = {
						increment_variable_effect = {
							VAR = destinations_processed_quartermaster_failure
							VAL = 1
						}
					}
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(quartermaster_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Just make up gibberish.
	option = {
		name = laamp_base_contract_schemes.2541.e

		scope:task_contract = {
			increment_variable_effect = {
				VAR = destinations_processed
				VAL = 1
			}
		}
		random_list = {
			25 = {
				desc = laamp_base_contract_schemes.2541.e.success
				custom_tooltip = laamp_base_contract_schemes.2541.e.success.tt
				scope:task_contract = {
					increment_variable_effect = {
						VAR = destinations_processed_guessed_success
						VAL = 1
					}
				}
				scope:location.county = {
					if = {
						limit = {
							holder = { is_ai = yes }
						}
						change_county_control = medium_county_control_loss
					}
				}
				if = {
					limit = {
						scope:employer = { has_trait = trusting }
					}
					custom_tooltip = laamp_base_contract_schemes.2541.e.tt.employer_has_trait.trusting
				}
				if = {
					limit = {
						scope:employer = { has_trait = lazy }
					}
					custom_tooltip = laamp_base_contract_schemes.2541.e.tt.employer_has_trait.lazy
				}
				# Employer traits.
				## Those that help you.
				modifier = {
					add = 25
					scope:employer = { has_trait = trusting }
				}
				modifier = {
					add = 15
					scope:employer = { has_trait = lazy }
				}
				## Those that hurt you.
				modifier = {
					add = -10
					scope:employer = { has_trait = paranoid }
				}
				modifier = {
					add = -10
					scope:employer = { has_trait = diligent }
				}
			}
			75 = {
				desc = laamp_base_contract_schemes.2541.e.failure
				custom_tooltip = laamp_base_contract_schemes.2541.e.failure.tt
				scope:task_contract = {
					increment_variable_effect = {
						VAR = destinations_processed_guessed_failure
						VAL = 1
					}
				}
				if = {
					limit = {
						scope:employer = { has_trait = paranoid }
					}
					custom_tooltip = laamp_base_contract_schemes.2541.e.tt.employer_has_trait.paranoid
				}
				if = {
					limit = {
						scope:employer = { has_trait = diligent }
					}
					custom_tooltip = laamp_base_contract_schemes.2541.e.tt.employer_has_trait.diligent
				}
				# Employer traits.
				## Those that help you.
				modifier = {
					add = -25
					scope:employer = { has_trait = trusting }
				}
				modifier = {
					add = -15
					scope:employer = { has_trait = lazy }
				}
				## Those that hurt you.
				modifier = {
					add = 10
					scope:employer = { has_trait = paranoid }
				}
				modifier = {
					add = 10
					scope:employer = { has_trait = diligent }
				}
			}
		}

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		# The AI should always prefer other options.
	}

	after = {
		if = {
			limit = { scope:task_contract.var:destinations_processed >= scope:employer.laamp_base_2011_desired_surveyable_holdings_per_tier_value }
			trigger_event = laamp_base_contract_schemes.2542
		}
		hidden_effect = {
			scope:random_local ?= { silent_disappearance_effect = yes }
			# And on we go!
			current_travel_plan = { resume_travel_plan = yes }
		}
	}
}

scripted_effect laamp_base_contract_schemes_2542_process_win_or_critical_win = {
	if = {
		limit = { scope:final_score_penalties <= 0 }
		save_scope_value_as = {
			name = result
			value = flag:crit_win
		}
		scope:task_contract = { complete_task_contract = success_critical }
	}
	else = {
		save_scope_value_as = {
			name = result
			value = flag:win
		}
		scope:task_contract = { complete_task_contract = success_standard }
	}
}

#	Outcome event.
laamp_base_contract_schemes.2542 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:result = flag:crit_win }
				desc = laamp_base_contract_schemes.2542.t.crit_win
			}
			triggered_desc = {
				trigger = { scope:result = flag:win }
				desc = laamp_base_contract_schemes.2542.t.win
			}
			triggered_desc = {
				trigger = { scope:result = flag:fail }
				desc = laamp_base_contract_schemes.2542.t.fail
			}
			triggered_desc = {
				trigger = { scope:result = flag:crit_fail }
				desc = laamp_base_contract_schemes.2542.t.crit_fail
			}
		}
	}
	desc = {
		desc = laamp_base_contract_schemes.2542.desc.intro
		first_valid = {
			# Own skill.
			triggered_desc = {
				trigger = {
					scope:final_score_destinations_processed_legit > scope:final_score_destinations_processed_quartermaster
					scope:final_score_destinations_processed_legit > scope:final_score_destinations_processed_lied
					scope:final_score_destinations_processed_legit > scope:final_score_destinations_processed_guessed
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.own_skill.honest.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.own_skill.honest.loss
						}
					}
				}
			}
			# Quartermaster's skill & they're a wreck.
			triggered_desc = {
				trigger = {
					scope:officer ?= { stress_level >= 2 }
					scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_legit
					scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_lied
					scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_guessed
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.quartermasters_stressed_and_wreckt.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.quartermasters_stressed_and_wreckt.loss
						}
					}
				}
			}
			# Quartermaster's skill.
			triggered_desc = {
				trigger = {
					exists = scope:officer
					scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_legit
					scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_lied
					scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_guessed
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.quartermasters_skill_sans_stress.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.quartermasters_skill_sans_stress.loss
						}
					}
				}
			}
			# Combi own skill/quartermaster's skill.
			triggered_desc = {
				trigger = {
					OR = {
						scope:final_score_destinations_processed_legit > scope:final_score_destinations_processed_lied
						scope:final_score_destinations_processed_legit > scope:final_score_destinations_processed_guessed
					}
					OR = {
						scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_lied
						scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_guessed
					}
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.combi_own_skill_and_quartermasters.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.combi_own_skill_and_quartermasters.loss
						}
					}
				}
			}
			# Lied.
			triggered_desc = {
				trigger = {
					scope:final_score_destinations_processed_lied > scope:final_score_destinations_processed_legit
					scope:final_score_destinations_processed_lied > scope:final_score_destinations_processed_quartermaster
					scope:final_score_destinations_processed_lied > scope:final_score_destinations_processed_guessed
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.own_skill.dishonest.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.own_skill.dishonest.loss
						}
					}
				}
			}
			# Guessed.
			triggered_desc = {
				trigger = {
					scope:final_score_destinations_processed_guessed > scope:final_score_destinations_processed_legit
					scope:final_score_destinations_processed_guessed > scope:final_score_destinations_processed_quartermaster
					scope:final_score_destinations_processed_guessed > scope:final_score_destinations_processed_lied
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.own_skill.guessed.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.own_skill.guessed.loss
						}
					}
				}
			}
			# Combi-lied/guessed.
			triggered_desc = {
				trigger = {
					OR = {
						scope:final_score_destinations_processed_lied > scope:final_score_destinations_processed_legit
						scope:final_score_destinations_processed_guessed > scope:final_score_destinations_processed_legit
					}
					OR = {
						scope:final_score_destinations_processed_lied > scope:final_score_destinations_processed_quartermaster
						scope:final_score_destinations_processed_guessed > scope:final_score_destinations_processed_quartermaster
					}
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:crit_win
									scope:result = flag:win
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.combi_own_skill_dishonest_and_guessed.win
						}
						triggered_desc = {
							trigger = {
								OR = {
									scope:result = flag:fail
									scope:result = flag:crit_fail
								}
							}
							desc = laamp_base_contract_schemes.2542.desc.method.combi_own_skill_dishonest_and_guessed.loss
						}
					}
				}
			}
			# Mixed.
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = {
							OR = {
								scope:result = flag:crit_win
								scope:result = flag:win
							}
						}
						desc = laamp_base_contract_schemes.2542.desc.method.mixed.win
					}
					triggered_desc = {
						trigger = {
							OR = {
								scope:result = flag:fail
								scope:result = flag:crit_fail
							}
						}
						desc = laamp_base_contract_schemes.2542.desc.method.mixed.loss
					}
				}
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:result = flag:crit_win
						scope:result = flag:win
					}
				}
				desc = laamp_base_contract_schemes.2542.desc.outro.win
			}
			triggered_desc = {
				trigger = {
					OR = {
						scope:result = flag:fail
						scope:result = flag:crit_fail
					}
				}
				desc = laamp_base_contract_schemes.2542.desc.outro.loss
			}
		}
	}
	window = scheme_successful_event
	theme = stewardship
	left_portrait = {
		character = scope:shown_officer
		triggered_animation = {
			trigger = {
				scope:officer ?= { stress_level >= 2 }
				OR = {
					scope:result = flag:crit_win
					scope:result = flag:win
				}
			}
			animation = stress
		}
		triggered_animation = {
			trigger = {
				OR = {
					scope:result = flag:crit_win
					scope:result = flag:win
				}
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				scope:officer ?= { stress_level >= 2 }
				OR = {
					scope:result = flag:fail
					scope:result = flag:crit_fail
				}
			}
			animation = crying
		}
		triggered_animation = {
			trigger = {
				OR = {
					scope:result = flag:fail
					scope:result = flag:crit_fail
				}
			}
			animation = disgust
		}
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					scope:result = flag:crit_win
					scope:result = flag:win
				}
			}
			animation = steward
		}
		triggered_animation = {
			trigger = {
				OR = {
					scope:result = flag:fail
					scope:result = flag:crit_fail
				}
			}
			animation = shock
		}
	}
	right_portrait = {
		character = scope:employer
		triggered_animation = {
			trigger = {
				OR = {
					scope:result = flag:crit_win
					scope:result = flag:win
				}
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				OR = {
					scope:result = flag:fail
					scope:result = flag:crit_fail
				}
			}
			animation = anger
		}
	}
	override_background = { reference = council_chamber }

	immediate = {
		# Sort a gender for the local rep.
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_gender }
		# And we want to make sure our background is urban.
		scope:random_local ?= {
			if = {
				limit = {
					is_ruler = no
					exists = court_owner
				}
				court_owner = { save_scope_as = bg_override_char }
			}
			else = {
				save_scope_as = bg_override_char
			}
		}
		# Alright, let's process our result.
		## Nab our final scores.
		### Total penalties.
		save_scope_value_as = {
			name = final_score_penalties
			value = {
				add = scope:task_contract.var:destinations_processed_legit_failure
				add = scope:task_contract.var:destinations_processed_quartermaster_failure
				add = scope:task_contract.var:destinations_processed_lied_failure
				add = scope:task_contract.var:destinations_processed_guessed_failure
			}
		}
		### Complete tallies.
		save_scope_value_as = {
			name = final_score_destinations_processed_legit
			value = {
				add = scope:task_contract.var:destinations_processed_legit_success
				add = scope:task_contract.var:destinations_processed_legit_failure
			}
		}
		save_scope_value_as = {
			name = final_score_destinations_processed_quartermaster
			value = {
				add = scope:task_contract.var:destinations_processed_quartermaster_success
				add = scope:task_contract.var:destinations_processed_quartermaster_failure
			}
		}
		save_scope_value_as = {
			name = final_score_destinations_processed_lied
			value = {
				add = scope:task_contract.var:destinations_processed_lied_success
				add = scope:task_contract.var:destinations_processed_lied_failure
			}
		}
		save_scope_value_as = {
			name = final_score_destinations_processed_guessed
			value = {
				add = scope:task_contract.var:destinations_processed_guessed_success
				add = scope:task_contract.var:destinations_processed_guessed_failure
			}
		}
		## Check to see if we cheated at any point.
		if = {
			limit = {
				OR = {
					scope:task_contract.var:destinations_processed_lied_success >= 1
					scope:task_contract.var:destinations_processed_lied_failure >= 1
					scope:task_contract.var:destinations_processed_guessed_success >= 1
					scope:task_contract.var:destinations_processed_guessed_failure >= 1
				}
			}
			save_scope_value_as = {
				name = cheated
				value = yes
			}
		}
		else = {
			save_scope_value_as = {
				name = cheated
				value = no
			}
		}
		## Right, now let's check success.
		### If we played it entirely straight, we get a lower margin of error.
		if = {
			limit = {
				scope:cheated = no
				scope:final_score_penalties <= 2
			}
			laamp_base_contract_schemes_2542_process_win_or_critical_win = yes
		}
		### Whereas if we cheated, we have to have been more thorough.
		else_if = {
			limit = {
				scope:cheated = yes
				scope:final_score_penalties <= 1
			}
			laamp_base_contract_schemes_2542_process_win_or_critical_win = yes
		}
		### Otherwise, we failed — still, if we failed honestly, it's a lesser penalty..
		else_if = {
			limit = { scope:cheated = no }
			save_scope_value_as = {
				name = result
				value = flag:fail
			}
			scope:task_contract = { complete_task_contract = failure_standard }
		}
		### Aaaand finally that means we're a failure _and_ a cheat.
		else = {
			save_scope_value_as = {
				name = result
				value = flag:crit_fail
			}
			scope:task_contract = { complete_task_contract = failure_critical }
		}
		# Last but not least, do we need to show our quartermaster?
		if = {
			limit = {
				scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_legit
				scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_lied
				scope:final_score_destinations_processed_quartermaster > scope:final_score_destinations_processed_guessed
			}
			scope:officer = { save_scope_as = shown_officer }
		}
	}

	# And we're done.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:result = flag:crit_win }
						desc = laamp_base_contract_schemes.2542.a.crit_win
					}
					triggered_desc = {
						trigger = { scope:result = flag:win }
						desc = laamp_base_contract_schemes.2542.a.win
					}
					triggered_desc = {
						trigger = { scope:result = flag:fail }
						desc = laamp_base_contract_schemes.2542.a.fail
					}
					triggered_desc = {
						trigger = { scope:result = flag:crit_fail }
						desc = laamp_base_contract_schemes.2542.a.crit_fail
					}
				}
			}
		}

		return_home = yes

		# No stress, no AI chance.
	}
}

##################################################
# Settle an administrative boundary dispute
# by Ewan Cowhig Croft
# 2661 - 2780
##################################################

scripted_trigger laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = {
	OR = {
		scope:employer.liege = { is_ai = yes }
		AND = {
			is_ai = no
			scope:employer.liege = { is_ai = no }
		}
	}
}

scripted_effect laamp_base_contract_schemes_2661_immediate_effect = {
	# If we've got an officer, flag them.
	court_position:$OFFICER$ ?= {
		if = {
			limit = { is_available_allow_travelling = yes }
			save_scope_as = officer
		}
	}
	# Check to see who our sacrifice will be, if anyone.
	if = {
		limit = { $SKILL$ < laamp_base_contract_schemes_2661_other_skill_threshold_value }
		ordered_courtier = {
			limit = {
				$SKILL$ >= @laamp_base_contract_schemes_2661_sacrifice_skill_threshold_value
				is_available_allow_travelling = yes
				NOR = {
					scope:officer ?= this
					is_player_heir_of = root
				}
			}
			order_by = $SKILL$
			save_scope_as = sacrifice
		}
	}
	# Note that we'll be taking our background from our employer.
	scope:employer = { save_scope_as = bg_override_char }
}

scripted_effect laamp_base_contract_schemes_2661_standard_duel_win_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = medium_county_control_gain
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2661_standard_duel_loss_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_failure_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			change_county_control = medium_county_control_loss
		}
	}
}

scripted_effect laamp_base_contract_schemes_2661_purpose_win_effect = {
	scope:task_contract = { complete_task_contract = success_camp_purpose }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = major_county_control_gain
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = {
	stress_impact = {
		diligent = minor_stress_loss
		lazy = medium_stress_gain
	}
}

scripted_effect laamp_base_contract_schemes_2661_delegated_job_stress_effect = {
	stress_impact = {
		lazy = minor_stress_loss
		diligent = medium_stress_gain
	}
}

scripted_effect laamp_base_contract_schemes_2661_stress_fallback_option_effect = {
	stress_impact = {
		base = major_stress_gain
		diligent = minor_stress_loss
		lazy = medium_stress_gain
	}
}

scripted_effect laamp_base_contract_schemes_2661_assign_visiting_courtier_effect = {
	# Transfer the courtier.
	hidden_effect = {
		root.current_travel_plan = { remove_character = scope:sacrifice }
	}
	scope:employer = { add_visiting_courtier = scope:sacrifice }
	# Set up their return.
	scope:sacrifice = {
		save_scope_as = visitor
		liege = {
			trigger_event = {
				id = ep3_laamp_flavour_ewan.9501
				years = {
					laamp_base_contract_schemes_2661_sacrifice_loan_length_min_value
					laamp_base_contract_schemes_2661_sacrifice_loan_length_max_value
				}
			}
		}
	}
}

#	Arguing over nature of landmark.
laamp_base_contract_schemes.2661 = {
	type = character_event
	title = laamp_base_contract_schemes.2661.t
	desc = {
		desc = laamp_base_contract_schemes.2661.desc
		desc = laamp_base_contract_schemes.2661.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	lower_left_portrait = scope:officer
	lower_center_portrait = scope:sacrifice
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2661_immediate_effect = {
			OFFICER = huntperson_camp_officer
			SKILL = intrigue
		}
	}

	# Stewardship auto-win.
	option = {
		name = laamp_base_contract_schemes.2661.a
		trigger = { stewardship >= @laamp_base_contract_schemes_2661_stewardship_threshold_value }
		skill = stewardship

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2662

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.2661.b
		trigger = { stewardship < @laamp_base_contract_schemes_2661_stewardship_threshold_value }

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2661.b.tt.success
				show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
				trigger_event = laamp_base_contract_schemes.2662
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2661.b.tt.failure
				show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_loss_effect = yes }
				trigger_event = laamp_base_contract_schemes.2663
			}
		}

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Intrigue auto-win.
	option = {
		name = laamp_base_contract_schemes.2661.c
		trigger = { intrigue >= laamp_base_contract_schemes_2661_other_skill_threshold_value }
		skill = intrigue

		save_scope_value_as = {
			name = resolution_type
			value = flag:secondary_skill
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2662

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Leave character with intrigue skill here.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:sacrifice }
						desc = laamp_base_contract_schemes.2661.d.sacrifice_exists
					}
					desc = laamp_base_contract_schemes.2661.d.sacrifice_unexists
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.2661.d.no_valid_char
				exists = scope:sacrifice
			}
		}
		show_as_unavailable = { intrigue < laamp_base_contract_schemes_2661_other_skill_threshold_value }

		laamp_base_contract_schemes_2661_assign_visiting_courtier_effect = yes
		custom_tooltip = laamp_base_contract_schemes.2661.d.tt.courtier_stays_here
		save_scope_value_as = {
			name = resolution_type
			value = flag:left_sacrifice
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2662

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Court position: huntsperson.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:officer }
						desc = laamp_base_contract_schemes.2661.e.officer_exists
					}
					desc = laamp_base_contract_schemes.2661.e.officer_unexists
				}
			}
		}
		trigger = { employs_court_position = huntperson_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_huntperson

		scope:officer ?= {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		save_scope_value_as = {
			name = resolution_type
			value = flag:officer
		}
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:officer }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
					trigger_event = laamp_base_contract_schemes.2662
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(huntperson_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_loss_effect = yes }
					trigger_event = laamp_base_contract_schemes.2663
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(huntperson_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		laamp_base_contract_schemes_2661_delegated_job_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Camp purpose: scholars.
	option = {
		name = laamp_base_contract_schemes.2661.f
		trigger = { has_realm_law = camp_purpose_scholars }
		reason = purpose_scholars

		save_scope_value_as = {
			name = resolution_type
			value = flag:camp_purpose
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_purpose_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2662

		# No stress here.
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stress solve it.
	option = {
		name = laamp_base_contract_schemes.2661.g
		trigger = {
			NOT = { has_realm_law = camp_purpose_scholars }
		}

		save_scope_value_as = {
			name = resolution_type
			value = flag:stress
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2662

		laamp_base_contract_schemes_2661_stress_fallback_option_effect = yes
		ai_chance = {
			# AI should try to take any other option.
			base = 0
		}
	}
}

#	Victory event.
laamp_base_contract_schemes.2662 = {
	type = character_event
	title = laamp_base_contract_schemes.2662.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2662.desc.resolution_type.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:secondary_skill }
				desc = laamp_base_contract_schemes.2662.desc.resolution_type.secondary_skill
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:left_sacrifice }
				desc = laamp_base_contract_schemes.2662.desc.resolution_type.left_sacrifice
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2662.desc.resolution_type.officer
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:camp_purpose }
				desc = laamp_base_contract_schemes.2662.desc.resolution_type.camp_purpose
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stress }
				desc = laamp_base_contract_schemes.2662.desc.resolution_type.stress
			}
		}
		triggered_desc = {
			trigger = { scope:resolution_type != flag:left_sacrifice }
			desc = laamp_base_contract_schemes.2662.desc.outro
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		if = {
			limit = { scope:resolution_type = flag:camp_purpose }
			laamp_base_contract_schemes_2661_purpose_win_effect = yes
		}
		else = { laamp_base_contract_schemes_2661_standard_duel_win_effect = yes }
	}

	# Congratulations!
	option = {
		name = laamp_base_contract_schemes.2662.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

#	Defeat event.
laamp_base_contract_schemes.2663 = {
	type = character_event
	title = laamp_base_contract_schemes.2663.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2663.desc.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2663.desc.officer
			}
		}
		desc = laamp_base_contract_schemes.2663.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2661_standard_duel_loss_effect = yes
	}

	# RIP.
	option = {
		name = laamp_base_contract_schemes.2663.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}


scripted_effect laamp_base_contract_schemes_2666_standard_duel_win_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = medium_county_control_gain
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2666_standard_duel_loss_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_failure_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			change_county_control = medium_county_control_loss
		}
	}
}

scripted_effect laamp_base_contract_schemes_2666_purpose_win_effect = {
	scope:task_contract = { complete_task_contract = success_camp_purpose }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = major_county_control_gain
			}
		}
	}
}

#	Debate over double dues from some villages.
laamp_base_contract_schemes.2666 = {
	type = character_event
	title = laamp_base_contract_schemes.2666.t
	desc = {
		desc = laamp_base_contract_schemes.2666.desc
		desc = laamp_base_contract_schemes.2666.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	lower_left_portrait = scope:officer
	lower_center_portrait = scope:sacrifice
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2661_immediate_effect = {
			OFFICER = quartermaster_camp_officer
			SKILL = diplomacy
		}
	}

	# Stewardship auto-win.
	option = {
		name = laamp_base_contract_schemes.2666.a
		trigger = { stewardship >= @laamp_base_contract_schemes_2661_stewardship_threshold_value }
		skill = stewardship

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2667

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.2666.b
		trigger = { stewardship < @laamp_base_contract_schemes_2661_stewardship_threshold_value }

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2666.b.tt.success
				show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
				trigger_event = laamp_base_contract_schemes.2667
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2666.b.tt.failure
				show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_loss_effect = yes }
				trigger_event = laamp_base_contract_schemes.2668
			}
		}

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Diplomacy auto-win.
	option = {
		name = laamp_base_contract_schemes.2666.c
		trigger = { diplomacy >= laamp_base_contract_schemes_2661_other_skill_threshold_value }
		skill = diplomacy

		save_scope_value_as = {
			name = resolution_type
			value = flag:secondary_skill
		}
		show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2667

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Leave character with diplomacy skill here.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:sacrifice }
						desc = laamp_base_contract_schemes.2666.d.sacrifice_exists
					}
					desc = laamp_base_contract_schemes.2666.d.sacrifice_unexists
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.2666.d.no_valid_char
				exists = scope:sacrifice
			}
		}
		show_as_unavailable = { diplomacy < laamp_base_contract_schemes_2661_other_skill_threshold_value }

		laamp_base_contract_schemes_2661_assign_visiting_courtier_effect = yes
		custom_tooltip = laamp_base_contract_schemes.2666.d.tt.courtier_stays_here
		save_scope_value_as = {
			name = resolution_type
			value = flag:left_sacrifice
		}
		show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2667

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Court position: quartermaster.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:officer }
						desc = laamp_base_contract_schemes.2666.e.officer_exists
					}
					desc = laamp_base_contract_schemes.2666.e.officer_unexists
				}
			}
		}
		trigger = { employs_court_position = quartermaster_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_quartermaster

		scope:officer ?= {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		save_scope_value_as = {
			name = resolution_type
			value = flag:officer
		}
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:officer }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
					trigger_event = laamp_base_contract_schemes.2667
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(quartermaster_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_loss_effect = yes }
					trigger_event = laamp_base_contract_schemes.2668
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(quartermaster_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		laamp_base_contract_schemes_2661_delegated_job_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Camp purpose: explorers
	option = {
		name = laamp_base_contract_schemes.2666.f
		trigger = { has_realm_law = camp_purpose_explorers }
		reason = purpose_explorers

		save_scope_value_as = {
			name = resolution_type
			value = flag:camp_purpose
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_purpose_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2667

		# No stress here.
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stress solve it.
	option = {
		name = laamp_base_contract_schemes.2666.g
		trigger = {
			NOT = { has_realm_law = camp_purpose_explorers }
		}

		save_scope_value_as = {
			name = resolution_type
			value = flag:stress
		}
		show_as_tooltip = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2667

		laamp_base_contract_schemes_2661_stress_fallback_option_effect = yes
		ai_chance = {
			# AI should try to take any other option.
			base = 0
		}
	}
}

#	Victory event.
laamp_base_contract_schemes.2667 = {
	type = character_event
	title = laamp_base_contract_schemes.2667.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2667.desc.resolution_type.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:secondary_skill }
				desc = laamp_base_contract_schemes.2667.desc.resolution_type.secondary_skill
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:left_sacrifice }
				desc = laamp_base_contract_schemes.2667.desc.resolution_type.left_sacrifice
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2667.desc.resolution_type.officer
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:camp_purpose }
				desc = laamp_base_contract_schemes.2667.desc.resolution_type.camp_purpose
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stress }
				desc = laamp_base_contract_schemes.2667.desc.resolution_type.stress
			}
		}
		triggered_desc = {
			trigger = { scope:resolution_type != flag:left_sacrifice }
			desc = laamp_base_contract_schemes.2667.desc.outro
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		if = {
			limit = { scope:resolution_type = flag:camp_purpose }
			laamp_base_contract_schemes_2666_purpose_win_effect = yes
		}
		else = { laamp_base_contract_schemes_2666_standard_duel_win_effect = yes }
	}

	# Congratulations!
	option = {
		name = laamp_base_contract_schemes.2667.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

#	Defeat event.
laamp_base_contract_schemes.2668 = {
	type = character_event
	title = laamp_base_contract_schemes.2668.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2668.desc.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2668.desc.officer
			}
		}
		desc = laamp_base_contract_schemes.2668.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2666_standard_duel_loss_effect = yes
	}

	# RIP.
	option = {
		name = laamp_base_contract_schemes.2668.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

scripted_effect laamp_base_contract_schemes_2671_standard_duel_win_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2071_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = medium_county_control_gain
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2671_standard_duel_loss_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2071_failure_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			change_county_control = medium_county_control_loss
		}
	}
}

scripted_effect laamp_base_contract_schemes_2671_purpose_win_effect = {
	scope:task_contract = { complete_task_contract = success_sacked_settlement }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title = {
			title_province = {
				add_province_modifier = { 
					modifier = recently_looted_modifier
					years = laamp_base_contract_schemes_2661_modifier_duration_value
				}
			}
			county = {	change_county_control = massive_county_control_loss }
		}
	}
}

#	Crumbling walls need extra duty.
laamp_base_contract_schemes.2671 = {
	type = character_event
	title = laamp_base_contract_schemes.2671.t
	desc = {
		desc = laamp_base_contract_schemes.2671.desc
		desc = laamp_base_contract_schemes.2671.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	lower_left_portrait = scope:officer
	lower_center_portrait = scope:sacrifice
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2661_immediate_effect = {
			OFFICER = head_porter_camp_officer
			SKILL = prowess
		}
	}

	# Stewardship auto-win.
	option = {
		name = laamp_base_contract_schemes.2671.a
		trigger = { stewardship >= @laamp_base_contract_schemes_2661_stewardship_threshold_value }
		skill = stewardship

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2672

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.2671.b
		trigger = { stewardship < @laamp_base_contract_schemes_2661_stewardship_threshold_value }

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2671.b.tt.success
				show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_win_effect = yes }
				trigger_event = laamp_base_contract_schemes.2672
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2671.b.tt.failure
				show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_loss_effect = yes }
				trigger_event = laamp_base_contract_schemes.2673
			}
		}

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Prowess auto-win.
	option = {
		name = laamp_base_contract_schemes.2671.c
		trigger = { prowess >= laamp_base_contract_schemes_2661_other_skill_threshold_value }
		skill = prowess

		save_scope_value_as = {
			name = resolution_type
			value = flag:secondary_skill
		}
		show_as_tooltip = {
			laamp_base_contract_schemes_2671_standard_duel_win_effect = yes
			add_prowess_skill = @laamp_base_contract_schemes_2671_prowess_gain_value
		}
		trigger_event = laamp_base_contract_schemes.2672

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Leave character with prowess skill here.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:sacrifice }
						desc = laamp_base_contract_schemes.2671.d.sacrifice_exists
					}
					desc = laamp_base_contract_schemes.2671.d.sacrifice_unexists
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.2671.d.no_valid_char
				exists = scope:sacrifice
			}
		}
		show_as_unavailable = { prowess < laamp_base_contract_schemes_2661_other_skill_threshold_value }

		laamp_base_contract_schemes_2661_assign_visiting_courtier_effect = yes
		custom_tooltip = laamp_base_contract_schemes.2671.d.tt.courtier_stays_here
		save_scope_value_as = {
			name = resolution_type
			value = flag:left_sacrifice
		}
		show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2672

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Court position: porter.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:officer }
						desc = laamp_base_contract_schemes.2671.e.officer_exists
					}
					desc = laamp_base_contract_schemes.2671.e.officer_unexists
				}
			}
		}
		trigger = { employs_court_position = head_porter_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_head_porter

		scope:officer ?= {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		save_scope_value_as = {
			name = resolution_type
			value = flag:officer
		}
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:officer }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_win_effect = yes }
					trigger_event = laamp_base_contract_schemes.2672
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(head_porter_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_loss_effect = yes }
					trigger_event = laamp_base_contract_schemes.2673
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(head_porter_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		laamp_base_contract_schemes_2661_delegated_job_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Camp purpose: brigands.
	option = {
		name = laamp_base_contract_schemes.2671.f
		trigger = { has_realm_law = camp_purpose_brigands }
		reason = purpose_brigands

		save_scope_value_as = {
			name = resolution_type
			value = flag:camp_purpose
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_purpose_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2672

		stress_impact = {
			sadistic = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			arbitrary = medium_stress_impact_loss
			greedy = minor_stress_impact_loss
			generous = minor_stress_impact_gain
			just = major_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 0
			# Take the auto-success — _if_ you're a bit of a prick.
			modifier = {
				add = 10000
				0 >= {
					add = ai_honor
					add = ai_compassion
				}
			}
		}
	}
	
	# Stress solve it.
	option = {
		name = laamp_base_contract_schemes.2671.g
		trigger = {
			NOT = { has_realm_law = camp_purpose_brigands }
		}

		save_scope_value_as = {
			name = resolution_type
			value = flag:stress
		}
		show_as_tooltip = { laamp_base_contract_schemes_2671_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2672

		laamp_base_contract_schemes_2661_stress_fallback_option_effect = yes
		ai_chance = {
			# AI should try to take any other option.
			base = 0
		}
	}
}

#	Victory event.
laamp_base_contract_schemes.2672 = {
	type = character_event
	title = laamp_base_contract_schemes.2672.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2672.desc.resolution_type.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:secondary_skill }
				desc = laamp_base_contract_schemes.2672.desc.resolution_type.secondary_skill
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:left_sacrifice }
				desc = laamp_base_contract_schemes.2672.desc.resolution_type.left_sacrifice
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2672.desc.resolution_type.officer
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:camp_purpose }
				desc = laamp_base_contract_schemes.2672.desc.resolution_type.camp_purpose
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stress }
				desc = laamp_base_contract_schemes.2672.desc.resolution_type.stress
			}
		}
		triggered_desc = {
			trigger = { scope:resolution_type != flag:left_sacrifice }
			desc = laamp_base_contract_schemes.2672.desc.outro
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		if = {
			limit = { scope:resolution_type = flag:camp_purpose }
			laamp_base_contract_schemes_2671_purpose_win_effect = yes
		}
		else = { laamp_base_contract_schemes_2671_standard_duel_win_effect = yes }
		if = {
			limit = { scope:resolution_type = flag:secondary_skill }
			add_prowess_skill = @laamp_base_contract_schemes_2671_prowess_gain_value
		}
	}

	# Congratulations!
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:resolution_type = flag:camp_purpose }
						desc = laamp_base_contract_schemes.2672.a.city_sacked
					}
					desc = laamp_base_contract_schemes.2672.a
				}
			}
		}

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

#	Defeat event.
laamp_base_contract_schemes.2673 = {
	type = character_event
	title = laamp_base_contract_schemes.2673.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2673.desc.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2673.desc.officer
			}
		}
		desc = laamp_base_contract_schemes.2673.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2671_standard_duel_loss_effect = yes
	}

	# RIP.
	option = {
		name = laamp_base_contract_schemes.2673.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

scripted_effect laamp_base_contract_schemes_2676_standard_duel_win_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title = {
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_2076_success_employer_modifier
					years = laamp_base_contract_schemes_2661_modifier_duration_value
				}
			}
			county = {
				if = {
					limit = { county_control < 100 }
					change_county_control = medium_county_control_gain
				}
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2676_standard_duel_loss_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title = {
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_2076_failure_employer_modifier
					years = laamp_base_contract_schemes_2661_modifier_duration_value
				}
			}
			county = {
				if = {
					limit = { county_control < 100 }
					change_county_control = medium_county_control_loss
				}
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2676_purpose_win_effect = {
	scope:task_contract = { complete_task_contract = success_camp_purpose }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title = {
			title_province = {
				add_province_modifier = {
					modifier = laamp_base_2076_success_employer_modifier
					years = laamp_base_contract_schemes_2661_modifier_duration_value
				}
			}
			county = {
				if = {
					limit = { county_control < 100 }
					change_county_control = major_county_control_gain
				}
			}
		}
	}
}

#	Horse pasturage dispute.
laamp_base_contract_schemes.2676 = {
	type = character_event
	title = laamp_base_contract_schemes.2676.t
	desc = {
		desc = laamp_base_contract_schemes.2676.desc
		desc = laamp_base_contract_schemes.2676.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	lower_left_portrait = scope:officer
	lower_center_portrait = scope:sacrifice
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2661_immediate_effect = {
			OFFICER = head_groom_camp_officer
			SKILL = martial
		}
	}

	# Stewardship auto-win.
	option = {
		name = laamp_base_contract_schemes.2676.a
		trigger = { stewardship >= @laamp_base_contract_schemes_2661_stewardship_threshold_value }
		skill = stewardship

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2677

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.2676.b
		trigger = { stewardship < @laamp_base_contract_schemes_2661_stewardship_threshold_value }

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2676.b.tt.success
				show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
				trigger_event = laamp_base_contract_schemes.2677
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2676.b.tt.failure
				show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_loss_effect = yes }
				trigger_event = laamp_base_contract_schemes.2678
			}
		}

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Martial auto-win.
	option = {
		name = laamp_base_contract_schemes.2676.c
		trigger = { martial >= laamp_base_contract_schemes_2661_other_skill_threshold_value }
		skill = martial

		save_scope_value_as = {
			name = resolution_type
			value = flag:secondary_skill
		}
		show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2677

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Leave character with martial skill here.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:sacrifice }
						desc = laamp_base_contract_schemes.2676.d.sacrifice_exists
					}
					desc = laamp_base_contract_schemes.2676.d.sacrifice_unexists
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.2676.d.no_valid_char
				exists = scope:sacrifice
			}
		}
		show_as_unavailable = { martial < laamp_base_contract_schemes_2661_other_skill_threshold_value }

		laamp_base_contract_schemes_2661_assign_visiting_courtier_effect = yes
		custom_tooltip = laamp_base_contract_schemes.2676.d.tt.courtier_stays_here
		save_scope_value_as = {
			name = resolution_type
			value = flag:left_sacrifice
		}
		show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2677

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Court position: groom.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:officer }
						desc = laamp_base_contract_schemes.2676.e.officer_exists
					}
					desc = laamp_base_contract_schemes.2676.e.officer_unexists
				}
			}
		}
		trigger = { employs_court_position = head_groom_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_head_groom

		scope:officer ?= {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		save_scope_value_as = {
			name = resolution_type
			value = flag:officer
		}
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:officer }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
					trigger_event = laamp_base_contract_schemes.2677
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(head_groom_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_loss_effect = yes }
					trigger_event = laamp_base_contract_schemes.2678
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(head_groom_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		laamp_base_contract_schemes_2661_delegated_job_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Camp purpose: mercenaries.
	option = {
		name = laamp_base_contract_schemes.2676.f
		trigger = { has_realm_law = camp_purpose_mercenaries }
		reason = purpose_mercenaries

		save_scope_value_as = {
			name = resolution_type
			value = flag:camp_purpose
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_purpose_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2677

		# No stress here.
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stress solve it.
	option = {
		name = laamp_base_contract_schemes.2676.g
		trigger = {
			NOT = { has_realm_law = camp_purpose_mercenaries }
		}

		save_scope_value_as = {
			name = resolution_type
			value = flag:stress
		}
		show_as_tooltip = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2677

		laamp_base_contract_schemes_2661_stress_fallback_option_effect = yes
		ai_chance = {
			# AI should try to take any other option.
			base = 0
		}
	}
}

#	Victory event.
laamp_base_contract_schemes.2677 = {
	type = character_event
	title = laamp_base_contract_schemes.2677.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2677.desc.resolution_type.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:secondary_skill }
				desc = laamp_base_contract_schemes.2677.desc.resolution_type.secondary_skill
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:left_sacrifice }
				desc = laamp_base_contract_schemes.2677.desc.resolution_type.left_sacrifice
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2677.desc.resolution_type.officer
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:camp_purpose }
				desc = laamp_base_contract_schemes.2677.desc.resolution_type.camp_purpose
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stress }
				desc = laamp_base_contract_schemes.2677.desc.resolution_type.stress
			}
		}
		triggered_desc = {
			trigger = { scope:resolution_type != flag:left_sacrifice }
			desc = laamp_base_contract_schemes.2677.desc.outro
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		if = {
			limit = { scope:resolution_type = flag:camp_purpose }
			laamp_base_contract_schemes_2676_purpose_win_effect = yes
		}
		else = { laamp_base_contract_schemes_2676_standard_duel_win_effect = yes }
	}

	# Congratulations!
	option = {
		name = laamp_base_contract_schemes.2677.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

#	Defeat event.
laamp_base_contract_schemes.2678 = {
	type = character_event
	title = laamp_base_contract_schemes.2678.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2678.desc.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2678.desc.officer
			}
		}
		desc = laamp_base_contract_schemes.2678.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2676_standard_duel_loss_effect = yes
	}

	# RIP.
	option = {
		name = laamp_base_contract_schemes.2678.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

scripted_effect laamp_base_contract_schemes_2681_standard_duel_win_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = medium_county_control_gain
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2681_standard_duel_loss_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_failure_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			change_county_control = medium_county_control_loss
		}
	}
}

scripted_effect laamp_base_contract_schemes_2681_purpose_win_effect = {
	scope:task_contract = { complete_task_contract = success_camp_purpose }
	if = {
		limit = { laamp_base_contract_schemes_2661_apply_effects_unless_against_poor_innocent_player_trigger = yes }
		scope:employer.primary_title.county = {
			add_county_modifier = {
				modifier = laamp_base_2031_success_employer_modifier
				years = laamp_base_contract_schemes_2661_modifier_duration_value
			}
			if = {
				limit = { county_control < 100 }
				change_county_control = major_county_control_gain
			}
		}
	}
}

#	Debate over ancient map.
laamp_base_contract_schemes.2681 = {
	type = character_event
	title = laamp_base_contract_schemes.2681.t
	desc = laamp_base_contract_schemes.2681.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	lower_left_portrait = scope:officer
	lower_center_portrait = scope:sacrifice
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_2661_immediate_effect = {
			OFFICER = master_bard_camp_officer
			SKILL = learning
		}
	}

	# Stewardship auto-win.
	option = {
		name = laamp_base_contract_schemes.2681.a
		trigger = { stewardship >= @laamp_base_contract_schemes_2661_stewardship_threshold_value }
		skill = stewardship

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2682

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.2681.b
		trigger = { stewardship < @laamp_base_contract_schemes_2661_stewardship_threshold_value }

		save_scope_value_as = {
			name = resolution_type
			value = flag:stewardship
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2681.b.tt.success
				show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
				trigger_event = laamp_base_contract_schemes.2682
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.2681.b.tt.failure
				show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_loss_effect = yes }
				trigger_event = laamp_base_contract_schemes.2683
			}
		}

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Learning auto-win.
	option = {
		name = laamp_base_contract_schemes.2681.c
		trigger = { learning >= laamp_base_contract_schemes_2661_other_skill_threshold_value }
		skill = learning

		save_scope_value_as = {
			name = resolution_type
			value = flag:secondary_skill
		}
		show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2682

		laamp_base_contract_schemes_2661_did_job_yourself_stress_effect = yes
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Leave character with learning skill here.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:sacrifice }
						desc = laamp_base_contract_schemes.2681.d.sacrifice_exists
					}
					desc = laamp_base_contract_schemes.2681.d.sacrifice_unexists
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.2681.d.no_valid_char
				exists = scope:sacrifice
			}
		}
		show_as_unavailable = { learning < laamp_base_contract_schemes_2661_other_skill_threshold_value }

		laamp_base_contract_schemes_2661_assign_visiting_courtier_effect = yes
		custom_tooltip = laamp_base_contract_schemes.2681.d.tt.courtier_stays_here
		save_scope_value_as = {
			name = resolution_type
			value = flag:left_sacrifice
		}
		show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2682

		# No stress here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Court position: bard.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:officer }
						desc = laamp_base_contract_schemes.2681.e.officer_exists
					}
					desc = laamp_base_contract_schemes.2681.e.officer_unexists
				}
			}
		}
		trigger = { employs_court_position = master_bard_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_master_bard

		scope:officer ?= {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		save_scope_value_as = {
			name = resolution_type
			value = flag:officer
		}
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:officer }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
					trigger_event = laamp_base_contract_schemes.2682
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(master_bard_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_loss_effect = yes }
					trigger_event = laamp_base_contract_schemes.2683
					# Raw aptitude.
					modifier = {
						add = {
							scope:officer ?= { add = "aptitude(master_bard_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
				}
			}
		}

		laamp_base_contract_schemes_2661_delegated_job_stress_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Camp purpose: legitimists.
	option = {
		name = laamp_base_contract_schemes.2681.f
		trigger = { has_realm_law = camp_purpose_legitimists }
		reason = purpose_legitimists

		save_scope_value_as = {
			name = resolution_type
			value = flag:camp_purpose
		}
		show_as_tooltip = { laamp_base_contract_schemes_2661_purpose_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2682

		# No stress here.
		ai_chance = {
			# If you can auto-win, do it.
			base = 10000
		}
	}
	
	# Stress solve it.
	option = {
		name = laamp_base_contract_schemes.2681.g
		trigger = {
			NOT = { has_realm_law = camp_purpose_legitimists }
		}

		save_scope_value_as = {
			name = resolution_type
			value = flag:stress
		}
		show_as_tooltip = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
		trigger_event = laamp_base_contract_schemes.2682

		laamp_base_contract_schemes_2661_stress_fallback_option_effect = yes
		ai_chance = {
			# AI should try to take any other option.
			base = 0
		}
	}
}

#	Victory event.
laamp_base_contract_schemes.2682 = {
	type = character_event
	title = laamp_base_contract_schemes.2682.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2682.desc.resolution_type.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:secondary_skill }
				desc = laamp_base_contract_schemes.2682.desc.resolution_type.secondary_skill
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:left_sacrifice }
				desc = laamp_base_contract_schemes.2682.desc.resolution_type.left_sacrifice
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2682.desc.resolution_type.officer
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:camp_purpose }
				desc = laamp_base_contract_schemes.2682.desc.resolution_type.camp_purpose
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stress }
				desc = laamp_base_contract_schemes.2682.desc.resolution_type.stress
			}
		}
		triggered_desc = {
			trigger = {
				NOR = {
					scope:resolution_type = flag:left_sacrifice
					scope:resolution_type = flag:camp_purpose
				}
			}
			desc = laamp_base_contract_schemes.2682.desc.outro
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = debating
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		if = {
			limit = { scope:resolution_type = flag:camp_purpose }
			laamp_base_contract_schemes_2681_purpose_win_effect = yes
		}
		else = { laamp_base_contract_schemes_2681_standard_duel_win_effect = yes }
	}

	# Congratulations!
	option = {
		name = laamp_base_contract_schemes.2682.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

#	Defeat event.
laamp_base_contract_schemes.2683 = {
	type = character_event
	title = laamp_base_contract_schemes.2683.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:resolution_type = flag:stewardship }
				desc = laamp_base_contract_schemes.2683.desc.stewardship
			}
			triggered_desc = {
				trigger = { scope:resolution_type = flag:officer }
				desc = laamp_base_contract_schemes.2683.desc.officer
			}
		}
		desc = laamp_base_contract_schemes.2683.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = alley_night }

	immediate = {
		laamp_base_contract_schemes_2681_standard_duel_loss_effect = yes
	}

	# RIP.
	option = {
		name = laamp_base_contract_schemes.2683.a

		return_home = yes

		# No stress here.
		# Single option, so no AI chance.
	}
}

##################################################
# Collect fake taxes
# by Ewan Cowhig Croft
# 2781 - 2900
##################################################

scripted_effect laamp_base_contract_schemes_2781_show_score_effect = {
	if = {
		limit = { scope:task_contract.var:wins_tally < scope:task_contract.var:win_t1_threshold }
		custom_tooltip = laamp_base_contract_schemes.2781.tt.current_total.sub_t1
	}
	else_if = {
		limit = { scope:task_contract.var:wins_tally < scope:task_contract.var:win_t2_threshold }
		custom_tooltip = laamp_base_contract_schemes.2781.tt.current_total.sub_t2
	}
	else_if = {
		limit = { scope:task_contract.var:wins_tally < scope:task_contract.var:win_t3_threshold }
		custom_tooltip = laamp_base_contract_schemes.2781.tt.current_total.sub_t3
	}
}

scripted_effect laamp_base_contract_schemes_2781_adjust_difficulty_effect = {
	custom_tooltip = laamp_base_contract_schemes.2781.tt.boost_difficulty.$DIFF_SPIKE$
	# Don't buff the difficulty for the AI, or they'll really have problems making solid judgements.
	if = {
		limit = { is_ai = no }
		scope:task_contract = {
			increment_variable_effect = {
				VAR = stewardship_diff
				VAL = $STEWARDSHIP$
			}
			increment_variable_effect = {
				VAR = intrigue_diff
				VAL = $INTRIGUE$
			}
			increment_variable_effect = {
				VAR = bard_diff
				VAL = $BARD$
			}
			increment_variable_effect = {
				VAR = stress_charge
				VAL = $STRESS$
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_2781_success_effect = {
	scope:task_contract = {
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 1
		}
	}
	custom_tooltip = laamp_base_contract_schemes.2781.tt.progress_towards_success
	trigger_event = laamp_base_contract_schemes.2782
	# Plus, let's lower the control here to make it feel tangible.
	location.county = {
		if = {
			limit = {
				# But don't hit unsuspecting players who haven't been informed of this.
				holder = { is_ai = yes }
			}
			change_county_control = major_county_control_loss
		}
	}
}

scripted_effect laamp_base_contract_schemes_2781_failure_effect = {
	scope:task_contract = {
		increment_variable_effect = {
			VAR = losses_tally
			VAL = 1
		}
	}
	if = {
		limit = { scope:task_contract.var:losses_tally <= 1 }
		custom_tooltip = laamp_base_contract_schemes.2781.tt.progress_towards_failure
	}
	else = { custom_tooltip = laamp_base_contract_schemes.2781.tt.contract_failed }
	trigger_event = laamp_base_contract_schemes.2783
}

scripted_effect laamp_base_contract_schemes_2781_duel_generic_effect = {
	duel = {
		skill = $SKILL$
		value = $DIFF$
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.2781.$SKILL$.tt.success
			laamp_base_contract_schemes_2781_success_effect = yes
		}
		# Defeat!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.2781.$SKILL$.tt.failure
			laamp_base_contract_schemes_2781_failure_effect = yes
		}
	}
}

#	Arrival at one of your marked targets.
laamp_base_contract_schemes.2781 = {
	type = character_event
	title = laamp_base_contract_schemes.2781.t
	desc = {
		# Surroundings.
		first_valid = {
			triggered_desc = {
				trigger = { scope:background = flag:alley_day }
				desc = laamp_base_contract_schemes.2781.desc.surroundings.alley_day
			}
			triggered_desc = {
				trigger = { scope:background = flag:alley_night }
				desc = laamp_base_contract_schemes.2781.desc.surroundings.alley_night
			}
			triggered_desc = {
				trigger = { scope:background = flag:tavern }
				desc = laamp_base_contract_schemes.2781.desc.surroundings.tavern
			}
			triggered_desc = {
				trigger = { scope:background = flag:docks }
				desc = laamp_base_contract_schemes.2781.desc.surroundings.docks
			}
			triggered_desc = {
				trigger = { scope:background = flag:condemned_village }
				desc = laamp_base_contract_schemes.2781.desc.surroundings.condemned_village
			}
		}
		desc = boilerplate.paragraph
		# Local mood.
		first_valid = {
			triggered_desc = {
				trigger = { scope:local_mood = flag:disapproval }
				desc = laamp_base_contract_schemes.2781.desc.local_mood.disapproval
			}
			triggered_desc = {
				trigger = { scope:local_mood = flag:anger }
				desc = laamp_base_contract_schemes.2781.desc.local_mood.anger
			}
			triggered_desc = {
				trigger = { scope:local_mood = flag:admiration }
				desc = laamp_base_contract_schemes.2781.desc.local_mood.admiration
			}
			triggered_desc = {
				trigger = { scope:local_mood = flag:dismissal }
				desc = laamp_base_contract_schemes.2781.desc.local_mood.dismissal
			}
			triggered_desc = {
				trigger = { scope:local_mood = flag:thinking }
				desc = laamp_base_contract_schemes.2781.desc.local_mood.thinking
			}
		}
		desc = laamp_base_contract_schemes.2781.desc.outro
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:local_char
		animation = disapproval
		triggered_animation = {
			trigger = { scope:local_mood = flag:disapproval }
			animation = disapproval
		}
		triggered_animation = {
			trigger = { scope:local_mood = flag:anger }
			animation = anger
		}
		triggered_animation = {
			trigger = { scope:local_mood = flag:admiration }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:local_mood = flag:dismissal }
			animation = dismissal
		}
		triggered_animation = {
			trigger = { scope:local_mood = flag:thinking }
			animation = thinking
		}
		hide_info = yes
	}
	lower_left_portrait = scope:bard
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:background = flag:alley_day }
			reference = alley_day
		}
		override_background = {
			trigger = { scope:background = flag:alley_night }
			reference = alley_night
		}
		override_background = {
			trigger = { scope:background = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:background = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:background = flag:condemned_village }
			reference = ce1_condemned_village
		}

	immediate = {
		# Roll our background tombola.
		random_list = {
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:alley_day
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:alley_night
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:tavern
				}
			}
			100 = {
				trigger = {
					location = { is_coastal = yes }
				}
				save_scope_value_as = {
					name = background
					value = flag:docks
				}
			}
			100 = {
				trigger = {
					location = {
						any_province_epidemic = { count >= 1 }
					}
				}
				save_scope_value_as = {
					name = background
					value = flag:condemned_village
				}
			}
		}
		# And our local mood tombola.
		random_list = {
			100 = {
				save_scope_value_as = {
					name = local_mood
					value = flag:disapproval
				}
			}
			100 = {
				save_scope_value_as = {
					name = local_mood
					value = flag:anger
				}
			}
			100 = {
				save_scope_value_as = {
					name = local_mood
					value = flag:admiration
				}
			}
			100 = {
				save_scope_value_as = {
					name = local_mood
					value = flag:dismissal
				}
			}
			100 = {
				save_scope_value_as = {
					name = local_mood
					value = flag:thinking
				}
			}
		}
		# If we have a suitable bard, grab them.
		court_position:master_bard_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					location = root.location
				}
				save_scope_as = bard
			}
		}
		# Generate a local to use.
		create_character = {
			template = merchant_template
			location = root.location
			culture = root.location.culture
			faith = root.location.faith
			save_scope_as = local_char
		}
		# Plus, stop us whilst we're here.
		hidden_effect = {
			current_travel_plan = { pause_travel_plan = yes }
		}
		# Finally, tell us where our total is at.
		laamp_base_contract_schemes_2781_show_score_effect = yes
	}

	# Stewardship.
	option = {
		name = laamp_base_contract_schemes.2781.a
		skill = stewardship

		laamp_base_contract_schemes_2781_duel_generic_effect = {
			SKILL = stewardship
			DIFF = scope:task_contract.var:stewardship_diff
		}

		laamp_base_contract_schemes_2781_adjust_difficulty_effect = {
			DIFF_SPIKE = stewardship
			STEWARDSHIP = 3
			INTRIGUE = 2
			BARD = 5
			STRESS = 5
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
	
	# Intrigue.
	option = {
		name = laamp_base_contract_schemes.2781.b
		skill = intrigue

		laamp_base_contract_schemes_2781_duel_generic_effect = {
			SKILL = intrigue
			DIFF = scope:task_contract.var:intrigue_diff
		}

		laamp_base_contract_schemes_2781_adjust_difficulty_effect = {
			DIFF_SPIKE = intrigue
			STEWARDSHIP = 2
			INTRIGUE = 3
			BARD = 5
			STRESS = 5
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Bard.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:bard }
						desc = laamp_base_contract_schemes.2781.c.bard_exists
					}
					desc = laamp_base_contract_schemes.2781.c.bard_dnae_exist
				}
			}
		}
		trigger = { employs_court_position = master_bard_camp_officer }
		show_as_unavailable = { always = yes }
		reason = have_master_bard

		custom_tooltip = option_boilerplate.tt.officer_aptitude
		# Extra exists check because otherwise show_as_unavailable'll cause errors.
		if = {
			limit = { exists = scope:bard }
			random_list = {
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.success
					send_interface_toast = {
						type = event_generic_good
						title = option_boilerplate.tt.officer_aptitude.success
						left_icon = scope:bard
						laamp_base_contract_schemes_2781_success_effect = yes
					}
					# Raw aptitude.
					modifier = {
						add = {
							scope:bard ?= { add = "aptitude(master_bard_camp_officer)" }
							multiply = 20
							min = 5
							max = 95
						}
						always = yes
					}
					# Adjusted for difficulty.
					modifier = {
						add = {
							value = scope:task_contract.var:bard_diff
							multiply = -1
						}
						always = yes
					}
				}
				0 = {
					desc = option_boilerplate.tt.officer_aptitude.failure
					send_interface_toast = {
						type = event_generic_bad
						title = option_boilerplate.tt.officer_aptitude.failure
						left_icon = scope:bard
						laamp_base_contract_schemes_2781_failure_effect = yes
					}
					# Raw aptitude.
					modifier = {
						add = {
							scope:bard ?= { add = "aptitude(master_bard_camp_officer)" }
							multiply = -20
							min = 5
							max = 95
						}
						always = yes
					}
					# Adjusted for difficulty.
					modifier = {
						add = scope:task_contract.var:bard_diff
						always = yes
					}
				}
			}
		}

		laamp_base_contract_schemes_2781_adjust_difficulty_effect = {
			DIFF_SPIKE = bard
			STEWARDSHIP = 2
			INTRIGUE = 2
			BARD = 15
			STRESS = 5
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:bard = { add = "aptitude(master_bard_camp_officer)" }
					multiply = 3
				}
				exists = scope:bard
			}
		}
	}
	
	# Stress.
	option = {
		name = laamp_base_contract_schemes.2781.d

		add_stress = scope:task_contract.var:stress_charge
		laamp_base_contract_schemes_2781_success_effect = yes

		laamp_base_contract_schemes_2781_adjust_difficulty_effect = {
			DIFF_SPIKE = stress
			STEWARDSHIP = 2
			INTRIGUE = 2
			BARD = 5
			STRESS = 15 
		}

		# The AI always plays it risky.
		ai_chance = { base = 0 }
	}
}

scripted_trigger laamp_base_contract_schemes_2782_middle_options_trigger = {
	scope:task_contract.var:wins_tally < scope:task_contract.var:win_t3_threshold
	trigger_if = {
		limit = { scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t1_threshold }
		scope:task_contract.var:losses_tally = 0
	}
}

#We bow out with what we currently have
scripted_effect laamp_base_contract_schemes_2782_bug_out_effect = {
	scope:task_contract = {
		# What should our result be?
		## Back out failure.
		if = {
			limit = { var:wins_tally < var:win_t1_threshold }
			scope:task_contract = { complete_task_contract = failure_qualified }
		}
		## Partial success.
		else_if = {
			limit = { var:wins_tally < var:win_t2_threshold }
			scope:task_contract = { complete_task_contract = success_qualified }
		}
		## Success.
		else = {
			scope:task_contract = { complete_task_contract = success_standard }
		}
	}
	# Remove our travel plan.
	hidden_effect = {
		return_home = yes
	}
}

#	Successful duel at a marked target.
laamp_base_contract_schemes.2782 = {
	type = character_event
	title = laamp_base_contract_schemes.2782.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t3_threshold }
				desc = laamp_base_contract_schemes.2782.desc.success_critical
			}
			triggered_desc = {
				trigger = { scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t2_threshold }
				desc = laamp_base_contract_schemes.2782.desc.success_standard
			}
			triggered_desc = {
				trigger = { scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t1_threshold }
				desc = laamp_base_contract_schemes.2782.desc.success_qualified
			}
			desc = laamp_base_contract_schemes.2782.desc.nothing_yet
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		animation = personality_bold
	}
	override_background = { reference = wilderness }

	immediate = {
		# Show our current score.
		laamp_base_contract_schemes_2781_show_score_effect = yes
	}

	# Full success!
	option = {
		name = laamp_base_contract_schemes.2782.a
		trigger = { scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t3_threshold }
		
		scope:task_contract = { complete_task_contract = success_critical }
		# Remove our travel plan.
		hidden_effect = {
			return_home = yes
		}

		# No stress here.
		# Only option, so no AI chance either.
	}
	
	# Keep going.
	option = {
		name = laamp_base_contract_schemes.2782.b
		trigger = { laamp_base_contract_schemes_2782_middle_options_trigger = yes }

		custom_tooltip = laamp_base_contract_schemes.2782.b.tt.travel_onwards
		current_travel_plan = { resume_travel_plan = yes }

		# No stress here.
		ai_chance = {
			# The AI keeps going till it wins or it loses a toss.
			base = 1000
		}
	}
	
	# Bug out with whatever you've got.
	option = {
		name = laamp_base_contract_schemes.2782.c
		trigger = { laamp_base_contract_schemes_2782_middle_options_trigger = yes }

		laamp_base_contract_schemes_2782_bug_out_effect = yes

		# No stress here.
		# No AI chance either — the AI won't bug out whilst it's on a hot streak.
	}
	
	# Can't achieve exceptional success any more, but we're above t2, so restrict to that.
	option = {
		name = laamp_base_contract_schemes.2782.d
		trigger = {
			scope:task_contract.var:wins_tally < scope:task_contract.var:win_t3_threshold
			scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t2_threshold
			scope:task_contract.var:losses_tally = 1
		}

		custom_tooltip = laamp_base_contract_schemes.2782.d.tt
		laamp_base_contract_schemes_2782_bug_out_effect = yes

		# No stress here.
		# Only option given, so no AI chance.
	}

	after = {
		# Clean up our local.
		hidden_effect = {
			scope:local_char = { silent_disappearance_effect = yes }
		}
	}
}

#	Failed duel at a marked target.
laamp_base_contract_schemes.2783 = {
	type = character_event
	title = laamp_base_contract_schemes.2783.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:task_contract.var:losses_tally = 2 }
				desc = laamp_base_contract_schemes.2783.desc.lost
			}
			desc = laamp_base_contract_schemes.2783.desc.losing
		}
	}
	theme = stewardship
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:task_contract.var:losses_tally = 1 }
			animation = stress
		}
		triggered_animation = {
			trigger = { scope:task_contract.var:losses_tally = 2 }
			animation = shock
		}
	}
	override_background = { reference = wilderness }

	immediate = {
		# Show our current score — _if_ we could still cut and run.
		if = {
			limit = { scope:task_contract.var:losses_tally = 1 }
			laamp_base_contract_schemes_2781_show_score_effect = yes
		}
	}

	# You have lost.
	option = {
		name = laamp_base_contract_schemes.2783.a
		trigger = { scope:task_contract.var:losses_tally = 2 }
		
		scope:scheme.task_contract = { complete_task_contract = failure_standard }

		# No stress here.
		# Only option, so no AI chance either.
	}
	
	# Well, only one loss so far.
	option = {
		name = laamp_base_contract_schemes.2783.b
		trigger = {
			scope:task_contract.var:losses_tally = 1
			scope:task_contract.var:wins_tally < scope:task_contract.var:win_t2_threshold
		}

		custom_tooltip = laamp_base_contract_schemes.2783.b.tt.travel_onwards
		current_travel_plan = { resume_travel_plan = yes }

		# No stress here.
		# AI-chance not needed, if the AI goofs, it should early out.
	}
	
	# Bug out with whatever you've got.
	option = {
		name = laamp_base_contract_schemes.2783.c
		trigger = {
			scope:task_contract.var:losses_tally = 1
			scope:task_contract.var:wins_tally < scope:task_contract.var:win_t2_threshold
		}

		laamp_base_contract_schemes_2782_bug_out_effect = yes

		# No stress here.
		ai_chance = {
			# If the AI has the chance, then they should bug out.
			base = 1000
		}
	}
	
	# Forced bug out.
	option = {
		name = laamp_base_contract_schemes.2783.d
		trigger = {
			scope:task_contract.var:losses_tally = 1
			scope:task_contract.var:wins_tally >= scope:task_contract.var:win_t2_threshold
		}

		custom_tooltip = laamp_base_contract_schemes.2783.d.tt
		laamp_base_contract_schemes_2782_bug_out_effect = yes

		# No stress here.
		ai_chance = {
			# If the AI has the chance, then they should bug out.
			base = 1000
		}
	}

	after = {
		# Clean up our local.
		hidden_effect = {
			scope:local_char = { silent_disappearance_effect = yes }
		}
	}
}











##################################################
# SETUP — INTRIGUE

##################################################
# Provide intelligence from your trips (setup)
# by Ewan Cowhig Croft
# 3001 - 3010
##################################################

#	Intro event.
laamp_base_contract_schemes.3001 = {
	type = character_event
	title = laamp_base_contract_schemes.3001.t
	desc = laamp_base_contract_schemes.3001.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:employer
		animation = personality_cynical
	}
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.3001.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_thief
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_socialite
			add_agent_slot = agent_infiltrator
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.3001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_thief
			add_agent_slot = agent_outcast
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.3001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_diplomat
			# Speed.
			add_agent_slot = agent_socialite
			add_agent_slot = agent_socialite
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.3002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.3002.t
	desc = laamp_base_contract_schemes.3002.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:employer
		animation = personality_rational
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_3001_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.3003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.3003.t
	desc = laamp_base_contract_schemes.3003.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:employer
		animation = disgust
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = { add_stress = medium_stress_gain }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_3004_organise_travel_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		on_arrival_event = laamp_base_contract_schemes.3301
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.3005
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.3004 = {
	type = character_event
	title = laamp_base_contract_schemes.3004.t
	desc = laamp_base_contract_schemes.3004.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:employer
		animation = schadenfreude
	}
	lower_center_portrait = scope:target
	override_background = { reference = corridor_night }

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
		# Alright, let's grab our best rulers.
		scope:employer = {
			# First, put everyone valid in a pot.
			## Neighbouring same-rank.
			every_neighboring_and_across_water_realm_same_rank_owner = {
				limit = {
					laamp_base_3001_valid_neighbours_trigger = { EMPLOYER = scope:employer }
				}
				add_to_list = potential_targets_list
			}
			## Emperors get a few extras hucked in the pot.
			if = {
				limit = { highest_held_title_tier >= tier_empire }
				every_neighboring_and_across_water_top_liege_realm_owner = {
					limit = {
						highest_held_title_tier >= tier_kingdom
						laamp_base_3001_valid_neighbours_trigger = { EMPLOYER = scope:employer }
					}
					add_to_list = potential_targets_list
				}
			}
			# Okay, now we've got a list, let's iterate over it and see what we can get.
			## First, sort our final targets.
			ordered_in_list = {
				list = potential_targets_list
				order_by = "opinion(scope:employer)"
				max = 3
				check_range_bounds = no
				add_to_list = actual_targets_list
			}
			## Now, pick the best one.
			ordered_in_list = {
				list = actual_targets_list
				order_by = {
					capital_province = { value = "squared_distance(root.location)" }
					multiply = -1
				}
				max = 3
				check_range_bounds = no
				if = {
					limit = {
						NOT = { exists = scope:destination_1 }
					}
					capital_county = { save_scope_as = destination_1 }
				}
				else_if = {
					limit = {
						NOT = {
							this.capital_county = scope:destination_1
							exists = scope:destination_2
						}
					}
					capital_county = { save_scope_as = destination_2 }
				}
				else_if = {
					limit = {
						NOT = {
							this.capital_county = scope:destination_1
							this.capital_county = scope:destination_2
							exists = scope:destination_3
						}
					}
					capital_county = { save_scope_as = destination_3 }
				}
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.3004.a

		custom_tooltip = travel.stationary_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.3004.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.3004.tt.explanation
		laamp_base_contract_schemes_3004_organise_travel_effect = {
			DOMICILE = no
			RETURN = yes
			EVENT_FIRE = all_but_last
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.3004.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.3004.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.3004.tt.explanation
		laamp_base_contract_schemes_3004_organise_travel_effect = {
			DOMICILE = yes
			RETURN = no
			EVENT_FIRE = all
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.3005 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		send_interface_message = {
			title = contract_invalidated_title
			type = intrigue_contract_scheme_invalidated_message
		}
	}
}

##################################################
# Murder a character's rival (setup)
# by Ewan Cowhig Croft
# 3011 - 3030
##################################################

#	Intro event.
laamp_base_contract_schemes.3011 = {
	type = character_event
	title = laamp_base_contract_schemes.3011.t
	desc = laamp_base_contract_schemes.3011.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:employer
		animation = personality_vengeful
	}
	lower_center_portrait = scope:target
	override_background = { reference = study }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract = {
			task_contract_employer = { save_scope_as = employer }
			var:target = { save_scope_as = target }
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.3011.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_assassin
			add_agent_slot = agent_assassin
			# Speed.
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_footpad
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.3011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_assassin
			add_agent_slot = agent_assassin
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_infiltrator
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.3011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Speed.
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_footpad
			# Success.
			add_agent_slot = agent_assassin
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on secrecy agents.
	option = {
		name = laamp_base_contract_schemes.3011.c
		reason = give_me_secrecy_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SECRECY

		scope:scheme = {
			# Secrecy.
			add_agent_slot = agent_lookout
			add_agent_slot = agent_lookout
			add_agent_slot = agent_decoy
			# Success.
			add_agent_slot = agent_assassin
			# Speed.
			add_agent_slot = agent_infiltrator
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		hidden_effect = {
			if = {
				limit = {
					domicile ?= { has_domicile_parameter = camp_unlocks_poisoner_scheme_agents }
				}
				scope:scheme = { add_agent_slot = agent_poisoner }
			}
		}
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.3012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.3012.t
	desc = laamp_base_contract_schemes.3012.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	lower_center_portrait = scope:target
	override_background = { reference = council_chamber }

	immediate = {
		# Employer outcome.
		scope:employer = { add_stress = massive_stress_loss }
		scope:scheme.task_contract = { complete_task_contract = success_standard }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3012.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.3013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.3013.t
	desc = laamp_base_contract_schemes.3013.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = go_to_your_room
	}
	lower_center_portrait = scope:target
	override_background = { reference = council_chamber }

	immediate = {
		# Employer outcome.
		scope:employer = { add_stress = massive_stress_gain }
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3013.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Abduct a character's rival (setup)
# by Ewan Cowhig Croft
# 3021 - 3030
##################################################

#	Intro event.
laamp_base_contract_schemes.3021 = {
	type = character_event
	title = laamp_base_contract_schemes.3021.t
	desc = laamp_base_contract_schemes.3021.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = personality_vengeful
	}
	lower_center_portrait = scope:target
	override_background = { reference = corridor_night }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract = {
			task_contract_employer = { save_scope_as = employer }
			var:target = { save_scope_as = target }
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.3021.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thug
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_infiltrator
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.3021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thug
			add_agent_slot = agent_thug
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_footpad
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.3021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_infiltrator
			# Success.
			add_agent_slot = agent_thug
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on secrecy agents.
	option = {
		name = laamp_base_contract_schemes.3021.c
		reason = give_me_secrecy_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SECRECY

		scope:scheme = {
			# Secrecy.
			add_agent_slot = agent_lookout
			add_agent_slot = agent_lookout
			add_agent_slot = agent_decoy
			# Success.
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.3022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.3022.t
	desc = laamp_base_contract_schemes.3022.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:employer
		animation = bribing
	}
	lower_center_portrait = scope:target
	override_background = { reference = throne_room }

	immediate = {
		# Employer outcome.
		imprison_character_effect = {
			TARGET = scope:target
			IMPRISONER = scope:employer
		}
		scope:employer = {
			add_stress = major_stress_loss
		}
		scope:scheme.task_contract = { complete_task_contract = success_standard }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3022.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.3023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.3023.t
	desc = laamp_base_contract_schemes.3023.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = disapproval
	}
	lower_center_portrait = scope:target
	override_background = { reference = study }

	immediate = {
		# Employer outcome.
		scope:employer = { add_stress = major_stress_gain }
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3023.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Attack the property of a character's rival (setup)
# by Ewan Cowhig Croft
# 3031 - 3040
##################################################

#	Intro event.
laamp_base_contract_schemes.3031 = {
	type = character_event
	title = laamp_base_contract_schemes.3031.t
	desc = laamp_base_contract_schemes.3031.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	lower_center_portrait = scope:target
	override_background = { reference = courtyard }
	orphan = yes
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract = {
			task_contract_employer = { save_scope_as = employer }
			var:target = { save_scope_as = target }
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.3031.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			add_agent_slot = agent_thug
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_planner
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.3031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			add_agent_slot = agent_thug
			add_agent_slot = agent_thug
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_planner
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.3031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_planner
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.3032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.3032.t
	desc = laamp_base_contract_schemes.3032.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = happiness
	}
	lower_center_portrait = scope:target
	override_background = { reference = study }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { save_scope_as = task_contract }
		scope:task_contract.var:target = { save_scope_as = target }
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = { add_dread = medium_dread_gain }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.3033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.3033.t
	desc = laamp_base_contract_schemes.3033.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:employer
		animation = disgust
	}
	lower_center_portrait = scope:target
	override_background = { reference = courtyard }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:task_contract.var:target = { save_scope_as = target }
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_dread = medium_dread_loss
			add_stress = medium_stress_gain
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_3034_organise_travel_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		on_arrival_event = laamp_base_contract_schemes.3661
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.3035
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.3034 = {
	type = character_event
	title = laamp_base_contract_schemes.3034.t
	desc = laamp_base_contract_schemes.3034.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = schadenfreude
	}
	lower_center_portrait = scope:target
	override_background = { reference = corridor_night }

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
		scope:target = {
			if = {
				limit = { is_ruler = yes }
				capital_county = { save_scope_as = destination_1 }
			}
			else = {
				location.county = { save_scope_as = destination_1 }
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.3034.a

		custom_tooltip = travel.stationary_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.3034.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.3034.tt.explanation
		if = {
			limit = {
				scope:target.location = root.location
			}
			trigger_event = laamp_base_contract_schemes.3661
		}
		else = {
			laamp_base_contract_schemes_3034_organise_travel_effect = {
				DOMICILE = no
				RETURN = yes
				EVENT_FIRE = all_but_last
			}
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.3034.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.3034.tt.destination_list
		custom_tooltip = laamp_base_contract_schemes.3034.tt.explanation
		if = {
			limit = {
				scope:target.location = root.location
			}
			trigger_event = laamp_base_contract_schemes.3661
		}
		else = {
			laamp_base_contract_schemes_3034_organise_travel_effect = {
				DOMICILE = yes
				RETURN = no
				EVENT_FIRE = all
			}
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.3035 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		send_interface_message = {
			title = contract_invalidated_title
			type = intrigue_contract_scheme_invalidated_message
		}
	}
}

##################################################
# Heist from a ruler's treasury (setup)
# by Ewan Cowhig Croft
# 3041 - 3050
##################################################

#	Intro event.
laamp_base_contract_schemes.3041 = {
	type = character_event
	title = laamp_base_contract_schemes.3041.t
	desc = laamp_base_contract_schemes.3041.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:employer
		animation = steward
	}
	override_background = { reference = alley_night }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.3041.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			add_agent_slot = agent_thief
			add_agent_slot = agent_scout
			# Speed.
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.3041.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			add_agent_slot = agent_thief
			add_agent_slot = agent_thug
			add_agent_slot = agent_scout
			# Speed.
			add_agent_slot = agent_infiltrator
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.3041.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_infiltrator
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on secrecy agents.
	#option = {
		#name = laamp_base_contract_schemes.3021.c
		#reason = give_me_secrecy_agents
		#flavor = EVENT_WINDOW_OPTION_AGENTS_SECRECY

		#scope:scheme = {
			# Secrecy.
			#add_agent_slot = agent_lookout
			#add_agent_slot = agent_lookout
			#add_agent_slot = agent_decoy
			# Success.
			#add_agent_slot = agent_thief
			# Speed.
			#add_agent_slot = agent_infiltrator
		#}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	#}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.3042 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.3042.t
	desc = laamp_base_contract_schemes.3042.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = random_weapon_coup_degrace
	}
	right_portrait = {
		character = scope:employer
		animation = fear
	}
	override_background = { reference = alley_night }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:employer = { save_scope_as = bg_override_char }
		# Compile all of our agents for the follow-up event, if we choose to go for it.
		scope:scheme = {
			every_scheme_agent_character = { add_to_list = former_agents_list }
		}
		# Aaaand check what our hauls would be.
		## First we remember root as a scope so that the tooltips won't have a little freak out at trying to do ROOT.Char.Var.
		save_scope_as = varcheck
		## Then sort our main variable.
		### First, our constituent values — we want to register these now as we're gonna use them in the success event chain.
		scope:employer = {
			save_scope_value_as = {
				name = contribution_gold
				value = {
					value = gold
					multiply = 0.5
					min = 0
				}
			}
			save_scope_value_as = {
				name = contribution_prestige
				value = {
					value = prestige
					multiply = 0.25
					min = 0
				}
			}
			save_scope_value_as = {
				name = contribution_piety
				value = {
					value = piety
					multiply = 0.25
					min = 0
				}
			}
		}
		### Now the variable itself.
		set_variable = {
			name = haul_possible
			value = {
				add = scope:contribution_gold
				add = scope:contribution_prestige
				add = scope:contribution_piety
				min = {
					value = 50
					add = {
						value = scope:employer.highest_held_title_tier
						# Adjust back down for barons.
						add = -1
						# Now boost it a bit per tier.
						multiply = 25
					}
				}
				floor = yes
			}
		}
		## Plus our increments.
		if = {
			limit = { var:haul_possible >= 750 }
			set_variable = {
				name = haul_increment
				value = 100
			}
		}
		else_if = {
			limit = { var:haul_possible >= 500 }
			set_variable = {
				name = haul_increment
				value = 75
			}
		}
		else = {
			set_variable = {
				name = haul_increment
				value = 50
			}
		}
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_3041_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3042.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes
		# If we're not using them, lose the variables.
		remove_variable = haul_possible
		remove_variable = haul_increment

		ai_chance = {
			ai_value_modifier = {
				ai_boldness = -2
				ai_greed = -2
			}
		}
	}

	# What if... we went back for more...
	option = {
		name = laamp_base_contract_schemes.3042.b
		skill = intrigue

		custom_tooltip = laamp_base_contract_schemes.3042.b.tt.possible_haul
		custom_tooltip = laamp_base_contract_schemes.3042.b.tt.explanation
		custom_tooltip = laamp_base_contract_schemes.3042.b.tt.current_earnings
		custom_tooltip = laamp_base_contract_schemes.3042.b.tt.you_go_back_for_more

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes

		# Our tracking variables.
		## The actual variables.
		set_variable = {
			name = haul_actual
			value = 0
		}
		set_variable = {
			name = heist_failures
			value = 0
		}
		# And finally, launch into the bonus heist.
		trigger_event = laamp_base_contract_schemes.3781

		ai_chance = {
			ai_value_modifier = {
				ai_boldness = 2
				ai_greed = 2
			}
		}
	}
}

#	Failure event.
laamp_base_contract_schemes.3043 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.3043.t
	desc = laamp_base_contract_schemes.3043.desc
	theme = intrigue
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = alley_night }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_3041_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.3043.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = yes
	}
}

##################################################
# EXTRA — INTRIGUE

##################################################
# Provide intelligence from your trips
# by Ewan Cowhig Croft
# 3301 - 3420
##################################################

#	Try to gather some intelligence.
laamp_base_contract_schemes.3301 = {
	type = character_event
	title = laamp_base_contract_schemes.3301.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:local_vibes = flag:scandal_affair }
				desc = laamp_base_contract_schemes.3301.desc.scandal_affair
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:scandal_torture }
				desc = laamp_base_contract_schemes.3301.desc.scandal_torture
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:scandal_manslaughter }
				desc = laamp_base_contract_schemes.3301.desc.scandal_manslaughter
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:scandal_loan }
				desc = laamp_base_contract_schemes.3301.desc.scandal_loan
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:scandal_bribery }
				desc = laamp_base_contract_schemes.3301.desc.scandal_bribery
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:rumblings_war }
				desc = laamp_base_contract_schemes.3301.desc.rumblings_war
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:rumblings_murder }
				desc = laamp_base_contract_schemes.3301.desc.rumblings_murder
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:rumblings_affair }
				desc = laamp_base_contract_schemes.3301.desc.rumblings_affair
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:mundane_feast }
				desc = laamp_base_contract_schemes.3301.desc.mundane_feast
			}
			triggered_desc = {
				trigger = { scope:local_vibes = flag:mundane_nothing }
				desc = laamp_base_contract_schemes.3301.desc.mundane_nothing
			}
		}
	}
	theme = intrigue
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:current_char
		animation = stress
	}
	lower_right_portrait = scope:spymaster
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:background = flag:corridor_night }
			reference = corridor_night
		}
		override_background = {
			trigger = { scope:background = flag:corridor_day }
			reference = corridor_day
		}
		override_background = {
			trigger = { scope:background = flag:council_chamber }
			reference = council_chamber
		}
		override_background = {
			trigger = { scope:background = flag:courtyard }
			reference = courtyard
		}
		override_background = {
			trigger = { scope:background = flag:sitting_room }
			reference = sitting_room
		}
		override_background = {
			trigger = { scope:background = flag:study }
			reference = study
		}
		override_background = {
			trigger = { scope:background = flag:relaxing_room }
			reference = relaxing_room
		}
		override_background = {
			trigger = { scope:background = flag:throne_room }
			reference = throne_room
		}

	immediate = {
		# Sort some aesthetic scopes.
		location.county.holder = {
			# Save our current destination for the background.
			save_scope_as = bg_override_char
			# Plus a general ease scope.
			save_scope_as = current_char
		}
		location.barony = { save_scope_as = current_barony }
		# Work out who our duels are gonna be against.
		## Nab our spymaster.
		cp:councillor_spymaster ?= { save_scope_as = spymaster }
		## Check our intrigue duellist.
		if = {
			limit = {
				scope:spymaster ?= { intrigue >= scope:current_char.intrigue }
			}
			scope:spymaster = { save_scope_as = intrigue_duellist }
		}
		else = {
			scope:current_char = { save_scope_as = intrigue_duellist }
		}
		## And our diplo duellist.
		if = {
			limit = {
				scope:spymaster ?= { diplomacy >= scope:current_char.diplomacy }
			}
			scope:spymaster = { save_scope_as = diplomacy_duellist }
		}
		else = {
			scope:current_char = { save_scope_as = diplomacy_duellist }
		}
		# Alright, pick a random local _thing_ to be happening.
		random_list = {
			# Scandal: rumoured low-tier affair.
			100 = {
				trigger = {
					NOT = {
						scope:current_char.faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active }
					}
				}
				save_scope_value_as = {
					name = local_vibes
					value = flag:scandal_affair
				}
				# Weight up for horny court.
				modifier = {
					add = 500
					scope:current_char = {
						OR = {
							has_trait = lustful
							AND = {
								highest_held_title_tier >= tier_kingdom
								has_court_type = court_intrigue
							}
						}
					}
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:scandal_affair
				}
			}
			# Scandal: excessive torture.
			100 = {
				trigger = {
					# Might feel a bit weird when our ruler has a reputation.
					scope:current_char = {
						NOR = {
							has_trait = compassionate
							has_trait = forgiving
						}
					}
				}
				save_scope_value_as = {
					name = local_vibes
					value = flag:scandal_torture
				}
				# Weight up for sadist court.
				modifier = {
					add = 500
					scope:current_char = {
						OR = {
							has_trait = sadistic
							AND = {
								highest_held_title_tier >= tier_kingdom
								has_court_type = court_intrigue
							}
						}
					}
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:scandal_torture
				}
			}
			# Scandal: manslaughter.
			100 = {
				save_scope_value_as = {
					name = local_vibes
					value = flag:scandal_manslaughter
				}
				# Weight up for angy court.
				modifier = {
					add = 500
					scope:current_char = {
						OR = {
							has_trait = wrathful
							AND = {
								highest_held_title_tier >= tier_kingdom
								has_court_type = court_warlike
							}
						}
					}
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:scandal_manslaughter
				}
			}
			# Scandal: demanding interest for loan.
			100 = {
				save_scope_value_as = {
					name = local_vibes
					value = flag:scandal_loan
				}
				# Weight up for greedy court.
				modifier = {
					add = 500
					scope:current_char = {
						OR = {
							has_trait = greedy
							AND = {
								highest_held_title_tier >= tier_kingdom
								has_court_type = court_administrative
							}
						}
					}
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:scandal_loan
				}
			}
			# Scandal: excessive bribery.
			100 = {
				trigger = {
					# Might feel a bit weird when our ruler has a reputation.
					NOT = {
						scope:current_char = { has_trait = honest }
					}
				}
				save_scope_value_as = {
					name = local_vibes
					value = flag:scandal_bribery
				}
				# Weight up for greedy court.
				modifier = {
					add = 500
					scope:current_char = {
						OR = {
							has_trait = greedy
							AND = {
								highest_held_title_tier >= tier_kingdom
								has_court_type = court_administrative
							}
						}
					}
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:scandal_bribery
				}
			}
			# Rumblings: war.
			100 = {
				trigger = {
					# It'll look weird to go _ooo maybe a warrrr_ if they're literally fighting one.
					scope:current_char = { is_at_war = no }
				}
				save_scope_value_as = {
					name = local_vibes
					value = flag:rumblings_war
				}
				# Weight up for warlike AI.
				modifier = {
					add = 500
					scope:current_char = { ai_has_warlike_personality = yes }
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:rumblings_war
				}
			}
			# Rumblings: murder.
			100 = {
				save_scope_value_as = {
					name = local_vibes
					value = flag:rumblings_murder
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:rumblings_murder
				}
				# Weight up for ongoing murder.
				## Place this after the factor since it's a thing that's _actually_ happening.
				modifier = {
					add = 500
					scope:current_char = {
						any_scheme = { is_savable_murder_scheme_trigger = yes }
					}
				}
			}
			# Rumblings: dramatic cuckoldry.
			100 = {
				trigger = {
					NOT = {
						scope:current_char.faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active }
					}
				}
				save_scope_value_as = {
					name = local_vibes
					value = flag:rumblings_affair
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:rumblings_affair
				}
				# Weight up for AI abouts to be in trouble.
				## Place this after the factor since it's a thing that's _actually_ happening.
				modifier = {
					add = 500
					scope:current_char = {
						any_consort = {
							any_targeting_scheme = {
								OR = {
									scheme_type = seduce
									scheme_type = elope
								}
							}
						}
					}
				}
			}
			# Mundane: upcoming feast.
			100 = {
				trigger = {
					# Don't talk about stuff to come if you're already doing something.
					NOT = { exists = scope:current_char.involved_activity }
				}
				save_scope_value_as = {
					name = local_vibes
					value = flag:mundane_feast
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:mundane_feast
				}
			}
			# Mundane: naught but chitter-chatter.
			100 = {
				save_scope_value_as = {
					name = local_vibes
					value = flag:mundane_nothing
				}
				# Weight down for having just had this.
				modifier = {
					factor = 0.01
					scope:local_vibes ?= flag:mundane_nothing
				}
			}
		}
		# Plus a background.
		random_list = {
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:corridor_night
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:corridor_day
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:council_chamber
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:courtyard
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:sitting_room
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:study
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:relaxing_room
				}
			}
			100 = {
				save_scope_value_as = {
					name = background
					value = flag:throne_room
				}
			}
		}
		# Finally, note that we've progressed past another target in our list and might need to end.
		scope:task_contract = {
			increment_variable_effect = {
				VAR = destinations_processed
				VAL = 1
			}
		}
	}

	# Intrigue duel.
	option = {
		name = laamp_base_contract_schemes.3301.a
		skill = intrigue

		duel = {
			skill = intrigue
			target = scope:intrigue_duellist
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.3301.a.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.3301.a.tt.success
					left_icon = scope:current_char
					right_icon = scope:spymaster
					custom_tooltip = laamp_base_contract_schemes.3301.tt.plus_one_success
					scope:task_contract = {
						increment_variable_effect = {
							VAR = wins_tally
							VAL = 1
						}
					}
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.3301.a.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.3301.a.tt.failure
					left_icon = scope:current_char
					right_icon = scope:spymaster
					reverse_add_opinion = {
						target = scope:current_char
						modifier = suspicion_opinion
						opinion = -40
					}
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			# Add our raw skill.
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Diplo duel.
	option = {
		name = laamp_base_contract_schemes.3301.b
		skill = diplomacy

		duel = {
			skill = diplomacy
			target = scope:diplomacy_duellist
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.3301.b.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.3301.b.tt.success
					left_icon = scope:current_char
					right_icon = scope:spymaster
					custom_tooltip = laamp_base_contract_schemes.3301.tt.plus_one_success
					scope:task_contract = {
						increment_variable_effect = {
							VAR = wins_tally
							VAL = 1
						}
					}
				}
			}
			# Defeat.
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.3301.b.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.3301.b.tt.failure
					left_icon = scope:current_char
					right_icon = scope:spymaster
					reverse_add_opinion = {
						target = scope:current_char
						modifier = suspicion_opinion
						opinion = -40
					}
				}
			}
		}

		# No stress here.
		ai_chance = {
			base = 1
			# Add our raw skill.
			modifier = {
				add = diplomacy
				always = yes
			}
		}
	}
	
	# Burn prestige/opinion for auto-success.
	option = {
		name = laamp_base_contract_schemes.3301.c

		add_prestige = {
			value = -75
			multiply = {
				value = scope:current_char.highest_held_title_tier
				# Account for barons.
				add = -1
			}
		}
		reverse_add_opinion = {
			target = scope:current_char
			modifier = suspicion_opinion
			opinion = -60
		}
		custom_tooltip = laamp_base_contract_schemes.3301.tt.plus_one_success
		scope:task_contract = {
			increment_variable_effect = {
				VAR = wins_tally
				VAL = 1
			}
		}

		# No stress here.
		ai_chance = {
			base = 0
			# Only do this if you suck at both intrigue and diplomacy
			modifier = {
				add = {
					value = 30
					subtract = intrigue
					subtract = diplomacy
				}
				always = yes
			}
		}
	}
	
	# Skip this one.
	option = {
		name = laamp_base_contract_schemes.3301.d

		custom_tooltip = laamp_base_contract_schemes.3301.d.tt.skip_the_attempt
		reverse_add_opinion = {
			target = scope:current_char
			modifier = friendliness_opinion
			opinion = 30
		}

		# No stress for skipping out.
		# The AI should always try to make a serious go of things.
		ai_chance = { base = 0 }
	}

	after = {
		# Clear our override char for the results events.
		clear_saved_scope = bg_override_char
		# Plus our spymaster & related scopes, in case the next char doesn't have one.
		clear_saved_scope = spymaster
		clear_saved_scope = intrigue_duellist
		clear_saved_scope = diplomacy_duellist
		# If this was our last stop, fire the resolution event.
		if = {
			limit = { scope:task_contract.var:destinations_processed >= 3 }
			# Did we succeed?
			if = {
				limit = { scope:task_contract.var:wins_tally >= 1 }
				trigger_event = laamp_base_contract_schemes.3302
			}
			# Otherwise, we failed.
			else = { trigger_event = laamp_base_contract_schemes.3303 }
		}
	}
}

#	You dun good.
laamp_base_contract_schemes.3302 = {
	type = character_event
	title = laamp_base_contract_schemes.3302.t
	desc = {
		desc = laamp_base_contract_schemes.3302.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { var:wins_tally >= 3 }
				desc = laamp_base_contract_schemes.3302.desc.win.critical
			}
			triggered_desc = {
				trigger = { var:wins_tally >= 2 }
				desc = laamp_base_contract_schemes.3302.desc.win.standard
			}
			desc = laamp_base_contract_schemes.3302.desc.win.qualified
		}
		desc = laamp_base_contract_schemes.3302.desc.outro
	}
	theme = intrigue
	left_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = throne_room }

	immediate = {
		scope:task_contract = {
			if = {
				limit = { var:wins_tally >= 3 }
				complete_task_contract = success_critical
			}
			else_if = {
				limit = { var:wins_tally >= 2 }
				complete_task_contract = success_standard
			}
			else = { complete_task_contract = success_qualified }
		}
	}

	# A happy patron brings all manner of gifts.
	option = {
		name = laamp_base_contract_schemes.3302.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}
}

#	You dun bad.
laamp_base_contract_schemes.3303 = {
	type = character_event
	title = laamp_base_contract_schemes.3303.t
	desc = laamp_base_contract_schemes.3303.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:employer
		animation = dismissal
	}
	override_background = { reference = throne_room }

	immediate = {
		scope:task_contract = { complete_task_contract = failure_standard }
	}

	# Bah, leave this fool to HerHis plotting.
	option = {
		name = laamp_base_contract_schemes.3303.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}
}

##################################################
# Attack the property of a character's rival
# by Ewan Cowhig Croft
# 3661 - 3780
##################################################

# Forager, kenneler, or cook.
scripted_trigger laamp_base_contract_schemes_3661_poison_trigger = {
	OR = {
		scope:business_type = flag:winery
		scope:business_type = flag:kennels
		scope:business_type = flag:mews
	}
}

# Thief, huntsman, or chief engineer.
scripted_trigger laamp_base_contract_schemes_3661_arson_trigger = {
	OR = {
		scope:business_type = flag:fallback
		scope:business_type = flag:relaxing_room
		scope:business_type = flag:docks
		scope:business_type = flag:shrine
	}
}

# Master-of-Arms, Master-of-Spoils, or Man-Haggler.
scripted_trigger laamp_base_contract_schemes_3661_assault_trigger = {
	OR = {
		scope:business_type = flag:tavern
		scope:business_type = flag:market
		scope:business_type = flag:bridge
		scope:business_type = flag:inn_exterior
	}
}

scripted_effect laamp_base_contract_schemes_3661_opinion_loss_effect = {
	if = {
		limit = { scope:secrecy = flag:overt }
		reverse_add_opinion = {
			target = scope:target
			modifier = gallowsbait_scum_opinion
			opinion = -50
		}
		if = {
			limit = {
				NOT = { scope:target = scope:destination_1.holder }
			}
			reverse_add_opinion = {
				target = scope:destination_1.holder
				modifier = gallowsbait_scum_opinion
				opinion = $OWNER_LOSS$
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_3661_gallowsbait_give_max_effect = {
	laamp_rewards_apply_criminal_xp_effect = {
		TRACK = bandit
		XP_MAX = gallowsbait_xp_major_gain
		XP_MIN = gallowsbait_xp_major_gain
	}
}

scripted_effect laamp_base_contract_schemes_3661_gallowsbait_update_effect = {
	if = {
		limit = { scope:secrecy = flag:overt }
		laamp_base_contract_schemes_3661_gallowsbait_give_max_effect = yes
	}
	else = {
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = bandit
			XP_MAX = gallowsbait_xp_minor_gain
			XP_MIN = gallowsbait_xp_minor_gain
		}
	}
}

scripted_effect laamp_base_contract_schemes_3661_duel_success_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	scope:destination_1 = {
		if = {
			limit = {
				holder = { is_ai = yes }
			}
			title_province = {
				switch = {
					trigger = scope:business_type
					flag:fallback = {
						if = {
							limit = { has_building_or_higher = workshops_01 }
							destroy_or_downgrade_building_effect = { BUILDING = workshops }
						}
						else_if = {
							limit = { has_building_or_higher = blacksmiths_01 }
							destroy_or_downgrade_ducal_building_effect = { BUILDING = blacksmiths }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:inn_exterior = {
						if = {
							limit = { has_building_or_higher = longhouses_01 }
							destroy_or_downgrade_tribal_building_effect = { BUILDING = longhouses }
						}
						else_if = {
							limit = { has_building_or_higher = caravanserai_01 }
							destroy_or_downgrade_building_effect = { BUILDING = caravanserai }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:relaxing_room = {
						if = {
							limit = { has_building_or_higher = leisure_palace_01 }
							destroy_or_downgrade_ducal_building_effect = { BUILDING = leisure_palace }
						}
						else_if = {
							limit = { has_building_or_higher = royal_garden_01 }
							destroy_or_downgrade_ducal_building_effect = { BUILDING = royal_garden }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:winery = {
						scope:destination_1 = { change_county_control = massive_county_control_loss }
					}
					flag:tavern = {
						if = {
							limit = { has_building_or_higher = longhouses_01 }
							destroy_or_downgrade_tribal_building_effect = { BUILDING = longhouses }
						}
						else_if = {
							limit = { has_building_or_higher = caravanserai_01 }
							destroy_or_downgrade_building_effect = { BUILDING = caravanserai }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:docks = {
						if = {
							limit = { has_building_or_higher = common_tradeport_01 }
							destroy_or_downgrade_building_effect = { BUILDING = common_tradeport }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:kennels = {
						if = {
							limit = { has_building_or_higher = farm_estates_01 }
							destroy_or_downgrade_building_effect = { BUILDING = farm_estates }
						}
						else_if = {
							limit = { has_building_or_higher = hunting_grounds_01 }
							destroy_or_downgrade_building_effect = { BUILDING = hunting_grounds }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:shrine = {
						if = {
							limit = { has_building_or_higher = monastic_schools_01 }
							destroy_or_downgrade_building_effect = { BUILDING = monastic_schools }
						}
						else_if = {
							limit = { has_building_or_higher = outposts_01 }
							destroy_or_downgrade_building_effect = { BUILDING = outposts }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:mews = {
						if = {
							limit = { has_building_or_higher = farm_estates_01 }
							destroy_or_downgrade_building_effect = { BUILDING = farm_estates }
						}
						else_if = {
							limit = { has_building_or_higher = hunting_grounds_01 }
							destroy_or_downgrade_building_effect = { BUILDING = hunting_grounds }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:bridge = {
						if = {
							limit = { has_building_or_higher = tax_assessor_01 }
							destroy_or_downgrade_ducal_building_effect = { BUILDING = tax_assessor }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
					flag:market = {
						if = {
							limit = { has_building_or_higher = market_villages_01 }
							destroy_or_downgrade_tribal_building_effect = { BUILDING = market_villages }
						}
						else_if = {
							limit = { has_building_or_higher = guild_halls_01 }
							destroy_or_downgrade_building_effect = { BUILDING = guild_halls }
						}
						else_if = {
							limit = { has_building_or_higher = workshops_01 }
							destroy_or_downgrade_building_effect = { BUILDING = workshops }
						}
						else = {
							scope:destination_1 = { change_county_control = massive_county_control_loss }
						}
					}
				}
			}
		}
	}
	laamp_base_contract_schemes_3661_opinion_loss_effect = { OWNER_LOSS = -50 }
	# Burning down a shrine might cost us piety.
	if = {
		limit = { scope:business_type = flag:shrine }
		# Not great if it's our own faith.
		if = {
			limit = { faith = scope:target.faith }
			add_piety = medium_piety_loss
		}
		# Still not okay if it's righteous.
		else_if = {
			limit = {
				faith = {
					faith_hostility_level = {
						target = scope:target.faith
						value <= faith_fully_accepted_level
					}
				}
			}
			add_piety = minor_piety_loss
		}
		# Kinda bad if it's tolerated.
		else_if = {
			limit = {
				faith = {
					faith_hostility_level = {
						target = scope:target.faith
						value <= faith_astray_level
					}
				}
			}
			add_piety = miniscule_piety_loss
		}
		# Otherwise we don't care.
	}
	# Kennelers steal us some dogs.
	if = {
		limit = { scope:method = flag:kenneler }
		add_character_modifier = {
			modifier = laamp_base_3661_stole_dogs_modifier
			years = 20
		}
	}
	# Actual effect applied in event afters.
	show_as_tooltip = { laamp_base_contract_schemes_3661_gallowsbait_update_effect = yes }
}

scripted_effect laamp_base_contract_schemes_3661_duel_failure_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	laamp_base_contract_schemes_3661_opinion_loss_effect = { OWNER_LOSS = -20 }
	# Actual effect applied in event afters.
	show_as_tooltip = { laamp_base_contract_schemes_3661_gallowsbait_update_effect = yes }
}

scripted_effect laamp_base_contract_schemes_3661_roll_duel_effect = {
	duel = {
		skill = $SKILL$
		value = $DIFFICULTY$
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.3661.tt.duel_success
			show_as_tooltip = { laamp_base_contract_schemes_3661_duel_success_effect = yes }
			trigger_event = laamp_base_contract_schemes.3662
		}
		# Defeat.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.3661.tt.duel_failure
			show_as_tooltip = { laamp_base_contract_schemes_3661_duel_failure_effect = yes }
			trigger_event = laamp_base_contract_schemes.3663
		}
	}
}

scripted_effect laamp_base_contract_schemes_3661_roll_camp_officer_effect = {
	scope:officer = {
		stress_impact = {
			base = medium_stress_gain
			diligent = minor_stress_impact_loss
			lazy = medium_stress_impact_gain
		}
	}
	custom_tooltip = option_boilerplate.tt.officer_aptitude
	# Extra exists check because otherwise show_as_unavailable'll cause errors.
	random_list = {
		0 = {
			desc = option_boilerplate.tt.officer_aptitude.success
			show_as_tooltip = { laamp_base_contract_schemes_3661_duel_success_effect = yes }
			trigger_event = laamp_base_contract_schemes.3662
			# Raw aptitude.
			modifier = {
				add = {
					scope:officer ?= { add = add_camp_officer_aptitude_value }
					multiply = 20
					min = 5
					max = 95
				}
				always = yes
			}
		}
		0 = {
			desc = option_boilerplate.tt.officer_aptitude.failure
			show_as_tooltip = { laamp_base_contract_schemes_3661_duel_failure_effect = yes }
			trigger_event = laamp_base_contract_schemes.3663
			# Raw aptitude.
			modifier = {
				add = {
					scope:officer ?= { add = add_camp_officer_aptitude_value }
					multiply = -20
					min = 5
					max = 95
				}
				always = yes
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_3661_roll_secondary_skill_duel_stress_impact_effect = {
	stress_impact = {
		callous = miniscule_stress_impact_loss
		sadistic = miniscule_stress_impact_loss
		deceitful = miniscule_stress_impact_loss
		honest = minor_stress_impact_gain
		compassionate = minor_stress_impact_gain
	}
}

scripted_effect laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = {
	stress_impact = {
		lazy = miniscule_stress_impact_loss
		diligent = minor_stress_impact_gain
	}
}

#	You arrive at a place where you're supposed to do An Bad Thing.
laamp_base_contract_schemes.3661 = {
	type = character_event
	title = laamp_base_contract_schemes.3661.t
	desc = {
		desc = laamp_base_contract_schemes.3661.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:business_type = flag:fallback }
				desc = laamp_base_contract_schemes.3661.desc.business.fallback
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:inn_exterior }
				desc = laamp_base_contract_schemes.3661.desc.business.inn_exterior
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:relaxing_room }
				desc = laamp_base_contract_schemes.3661.desc.business.relaxing_room
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:winery }
				desc = laamp_base_contract_schemes.3661.desc.business.winery
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:tavern }
				desc = laamp_base_contract_schemes.3661.desc.business.tavern
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:docks }
				desc = laamp_base_contract_schemes.3661.desc.business.docks
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:kennels }
				desc = laamp_base_contract_schemes.3661.desc.business.kennels
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:shrine }
				desc = laamp_base_contract_schemes.3661.desc.business.shrine
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:mews }
				desc = laamp_base_contract_schemes.3661.desc.business.mews
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:bridge }
				desc = laamp_base_contract_schemes.3661.desc.business.bridge
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:market }
				desc = laamp_base_contract_schemes.3661.desc.business.market
			}
		}
		desc = laamp_base_contract_schemes.3661.desc.outro
	}
	theme = intrigue
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:target
		animation = shock
	}
	lower_center_portrait = scope:employer
	lower_left_portrait = scope:officer
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:business_type = flag:fallback }
			reference = alley_night
		}
		override_background = {
			trigger = { scope:business_type = flag:inn_exterior }
			reference = bp1_crossroads_inn
		}
		override_background = {
			trigger = { scope:business_type = flag:relaxing_room }
			reference = relaxing_room
		}
		override_background = {
			trigger = { scope:business_type = flag:winery }
			reference = bp1_wine_cellar
		}
		override_background = {
			trigger = { scope:business_type = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:business_type = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:business_type = flag:kennels }
			reference = ep2_dog_kennels
		}
		override_background = {
			trigger = { scope:business_type = flag:shrine }
			reference = holy_site_generic
		}
		override_background = {
			trigger = { scope:business_type = flag:mews }
			reference = ep2_hunt_falconry_mews
		}
		override_background = {
			trigger = { scope:business_type = flag:bridge }
			reference = ep2_travel_bridge
		}
		override_background = {
			trigger = { scope:business_type = flag:market }
			reference = market
		}

	immediate = {
		# Roll our business.
		random_list = {
			# alley
			100 = {
				save_scope_value_as = {
					name = business_type
					value = flag:fallback
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:martial
				}
			}
			# bp1_crossroads_inn
			100 = {
				trigger = {
					scope:target = {
						# Background is aggressively European in aesthetic.
						capital_county ?= {
							title_province = { geographical_region = ek_graphical_europe_like } #EK EDIT
						}
						# No tribals.
						NOR = {
							government_has_flag = government_is_tribal
							government_has_flag = government_is_nomadic
						}
					}
				}
				save_scope_value_as = {
					name = business_type
					value = flag:inn_exterior
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:martial
				}
			}
			# relaxing_room
			100 = {
				trigger = {
					scope:target = {
						# No tribals.
						NOR = {
							government_has_flag = government_is_tribal
							government_has_flag = government_is_nomadic
						}
					}
				}
				save_scope_value_as = {
					name = business_type
					value = flag:relaxing_room
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:prowess
				}
			}
			# wine_cellar
			100 = {
				trigger = {
					scope:target = {
						drinks_alcohol_trigger = yes
						# No tribals.
						NOR = {
							government_has_flag = government_is_tribal
							government_has_flag = government_is_nomadic
						}
					}
				}
				save_scope_value_as = {
					name = business_type
					value = flag:winery
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:prowess
				}
			}
			# tavern
			100 = {
				trigger = {
					scope:target = { drinks_alcohol_trigger = yes }
				}
				save_scope_value_as = {
					name = business_type
					value = flag:tavern
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:martial
				}
			}
			# docks
			100 = {
				trigger = {
					scope:destination_1.title_province = { is_coastal = yes }
				}
				save_scope_value_as = {
					name = business_type
					value = flag:docks
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:martial
				}
			}
			# kennels
			100 = {
				save_scope_value_as = {
					name = business_type
					value = flag:kennels
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:prowess
				}
			}
			# shrine/holy site generic
			100 = {
				trigger = {
					scope:target = {
						NOT = { has_trait = cynical }
						faith = scope:destination_1.faith
					}
				}
				save_scope_value_as = {
					name = business_type
					value = flag:shrine
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:prowess
				}
			}
			# mews
			100 = {
				trigger = {
					scope:target = {
						# No reason to keep hawks if you don't eat meat.
						is_vegetarian_trigger = no
						# No tribals.
						NOT = { government_has_flag = government_is_tribal }
					}
				}
				save_scope_value_as = {
					name = business_type
					value = flag:mews
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:martial
				}
			}
			# bridge
			100 = {
				trigger = {
					scope:destination_1.title_province = {
						OR = {
							terrain = plains
							terrain = farmlands
							terrain = hills
							terrain = mountains
							terrain = drylands
						}
					}
					scope:target = {
						# No tribals — the art won't work for it..
						NOR = {
							government_has_flag = government_is_tribal
							government_has_flag = government_is_nomadic
						}
					}
				}
				save_scope_value_as = {
					name = business_type
					value = flag:bridge
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:martial
				}
			}
			# market
			100 = {
				save_scope_value_as = {
					name = business_type
					value = flag:market
				}
				save_scope_value_as = {
					name = skill_check
					value = flag:prowess
				}
			}
		}
		# Now let's see what officers we could use.
		## First, grab all valid officers.
		court_position:chief_forager_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_poison_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:master_thief_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_arson_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:huntperson_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_arson_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:kennelperson_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_poison_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:chief_engineer_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_arson_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:person_haggler_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_assault_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:master_of_arms_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_assault_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:master_of_spoils_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_assault_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		court_position:camp_cook_camp_officer ?= {
			if = {
				limit = {
					is_available_allow_travelling = yes
					laamp_base_contract_schemes_3661_poison_trigger = yes
				}
				add_to_list = potential_officers_list
			}
		}
		# Now sort them to pick who's best.
		ordered_in_list = {
			list = potential_officers_list
			order_by = {
				# We put the kenneler first, even though this is out of order compared to every other usage of these officers in this event, to maximise visibility of the dog theft mechanics.
				if = {
					limit = { has_court_position = kennelperson_camp_officer }
					add = "aptitude(kennelperson_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = chief_forager_camp_officer }
					add = "aptitude(chief_forager_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = master_thief_camp_officer }
					add = "aptitude(master_thief_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = huntperson_camp_officer }
					add = "aptitude(huntperson_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = chief_engineer_camp_officer }
					add = "aptitude(chief_engineer_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = person_haggler_camp_officer }
					add = "aptitude(person_haggler_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = master_of_arms_camp_officer }
					add = "aptitude(master_of_arms_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = master_of_spoils_camp_officer }
					add = "aptitude(master_of_spoils_camp_officer)"
				}
				else_if = {
					limit = { has_court_position = camp_cook_camp_officer }
					add = "aptitude(camp_cook_camp_officer)"
				}
			}
			save_scope_as = officer
		}
	}

	# Intrigue duel.
	option = {
		name = laamp_base_contract_schemes.3661.a
		skill = intrigue

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:intrigue
		}
		laamp_base_contract_schemes_3661_roll_duel_effect = {
			SKILL = intrigue
			DIFFICULTY = decent_skill_rating
		}

		# No stress for the default option.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_rationality = 2 }
		}
	}
	
	# Martial auto-win.
	option = {
		name = laamp_base_contract_schemes.3661.b
		trigger = {
			scope:skill_check = flag:martial
			martial >= @laamp_base_contract_schemes_3661_martial_threshold_value
		}

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_foregone_extra_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:overt
		}
		save_scope_value_as = {
			name = method
			value = flag:martial
		}
		show_as_tooltip = { laamp_base_contract_schemes_3661_duel_success_effect = yes }
		trigger_event = laamp_base_contract_schemes.3662

		laamp_base_contract_schemes_3661_roll_secondary_skill_duel_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Martial duel.
	option = {
		name = laamp_base_contract_schemes.3661.c
		trigger = {
			scope:skill_check = flag:martial
			martial < @laamp_base_contract_schemes_3661_martial_threshold_value
		}

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_foregone_extra_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:overt
		}
		save_scope_value_as = {
			name = method
			value = flag:martial
		}
		laamp_base_contract_schemes_3661_roll_duel_effect = {
			SKILL = martial
			DIFFICULTY = medium_skill_rating
		}

		laamp_base_contract_schemes_3661_roll_secondary_skill_duel_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Prowess auto-win.
	option = {
		name = laamp_base_contract_schemes.3661.d
		trigger = {
			scope:skill_check = flag:prowess
			prowess >= @laamp_base_contract_schemes_3661_prowess_threshold_value
		}

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_foregone_extra_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:overt
		}
		save_scope_value_as = {
			name = method
			value = flag:prowess
		}
		show_as_tooltip = { laamp_base_contract_schemes_3661_duel_success_effect = yes }
		trigger_event = laamp_base_contract_schemes.3662

		laamp_base_contract_schemes_3661_roll_secondary_skill_duel_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Prowess duel.
	option = {
		name = laamp_base_contract_schemes.3661.e
		trigger = {
			scope:skill_check = flag:prowess
			prowess < @laamp_base_contract_schemes_3661_prowess_threshold_value
		}

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_foregone_extra_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:overt
		}
		save_scope_value_as = {
			name = method
			value = flag:prowess
		}
		laamp_base_contract_schemes_3661_roll_duel_effect = {
			SKILL = prowess
			DIFFICULTY = medium_skill_rating
		}

		laamp_base_contract_schemes_3661_roll_secondary_skill_duel_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = -2 }
		}
	}
	
	# Chief Forager
	option = {
		name = laamp_base_contract_schemes.3661.f
		trigger = {
			scope:officer ?= { has_court_position = chief_forager_camp_officer }
		}
		reason = have_chief_forager

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:forager
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Master Thief
	option = {
		name = laamp_base_contract_schemes.3661.g
		trigger = {
			scope:officer ?= { has_court_position = master_thief_camp_officer }
		}
		reason = have_master_thief

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:thief
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Huntperson
	option = {
		name = laamp_base_contract_schemes.3661.h
		trigger = {
			scope:officer ?= { has_court_position = huntperson_camp_officer }
		}
		reason = have_huntperson

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:huntperson
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Kennelperson
	option = {
		name = {
			text = {
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = { scope:business_type = flag:winery }
							desc = laamp_base_contract_schemes.3661.i.poison_barrels
						}
						triggered_desc = {
							trigger = { scope:business_type = flag:kennels }
							desc = laamp_base_contract_schemes.3661.i.steal_dogs
						}
						triggered_desc = {
							trigger = { scope:business_type = flag:mews }
							desc = laamp_base_contract_schemes.3661.i.dog_on_birds
						}
					}
				}
			}
		}
		trigger = {
			scope:officer ?= { has_court_position = kennelperson_camp_officer }
		}
		reason = have_kennelperson

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:kenneler
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Chief Engineer
	option = {
		name = laamp_base_contract_schemes.3661.j
		trigger = {
			scope:officer ?= { has_court_position = chief_engineer_camp_officer }
		}
		reason = have_chief_engineer

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:engineer
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Person Haggler
	option = {
		name = laamp_base_contract_schemes.3661.k
		trigger = {
			scope:officer ?= { has_court_position = person_haggler_camp_officer }
		}
		reason = have_person_haggler

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:haggler
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Master of Arms
	option = {
		name = laamp_base_contract_schemes.3661.l
		trigger = {
			scope:officer ?= { has_court_position = master_of_arms_camp_officer }
		}
		reason = have_master_of_arms

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:armsman
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Master of Spoils
	option = {
		name = laamp_base_contract_schemes.3661.m
		trigger = {
			scope:officer ?= { has_court_position = master_of_spoils_camp_officer }
		}
		reason = have_master_of_spoils

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:spoiler
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Camp Cook
	option = {
		name = laamp_base_contract_schemes.3661.n
		trigger = {
			scope:officer ?= { has_court_position = camp_cook_camp_officer }
		}
		reason = have_camp_cook

		custom_tooltip = laamp_base_contract_schemes.3661.tt.stealth_maintained_no_gallowsbait
		save_scope_value_as = {
			name = secrecy
			value = flag:stealthy
		}
		save_scope_value_as = {
			name = method
			value = flag:cook
		}
		laamp_base_contract_schemes_3661_roll_camp_officer_effect = yes

		laamp_base_contract_schemes_3661_roll_camp_officer_stress_impact_effect = yes
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
	
	# Dummy event option for when you have no officers.
	option = {
		name = laamp_base_contract_schemes.3661.o
		trigger = {
			# Yes, this is supposed to be here — we show this option if you're not valid for various other options.
			trigger_if = {
				limit = { laamp_base_contract_schemes_3661_poison_trigger = yes }
				custom_tooltip = {
					text = laamp_base_contract_schemes.3661.o.lacking_officers.forager_kenneler_cook
					always = no
				}
			}
			trigger_if = {
				limit = { laamp_base_contract_schemes_3661_arson_trigger = yes }
				custom_tooltip = {
					text = laamp_base_contract_schemes.3661.o.lacking_officers.thief_huntsman_engineer
					always = no
				}
			}
			trigger_if = {
				limit = { laamp_base_contract_schemes_3661_assault_trigger = yes }
				custom_tooltip = {
					text = laamp_base_contract_schemes.3661.o.lacking_officers.moa_mos_man_haggler
					always = no
				}
			}
		}
		show_as_unavailable = {
			NOT = { exists = scope:officer }
		}

		# No stress, no AI, no effects — this is just here to tell you you're missing out on an officer position option.
	}
	
	# Back off.
	## Mostly here for people who don't want to like... burn dogs to death or something.
	### ... the freaks.
	option = {
		name = laamp_base_contract_schemes.3661.p

		scope:task_contract = { complete_task_contract = failure_qualified }

		stress_impact = {
			craven = medium_stress_impact_loss
			brave = minor_stress_impact_gain
		}
		# No AI — the AI'll never back down from a challenge.
	}
}

#	You successfully destroy something.
laamp_base_contract_schemes.3662 = {
	type = character_event
	title = laamp_base_contract_schemes.3662.t
	window = scheme_successful_event
	desc = {
		desc = laamp_base_contract_schemes.3662.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:business_type = flag:fallback }
				desc = laamp_base_contract_schemes.3662.desc.business.fallback
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:inn_exterior }
				desc = laamp_base_contract_schemes.3662.desc.business.inn_exterior
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:relaxing_room }
				desc = laamp_base_contract_schemes.3662.desc.business.relaxing_room
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:winery }
				desc = laamp_base_contract_schemes.3662.desc.business.winery
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:tavern }
				desc = laamp_base_contract_schemes.3662.desc.business.tavern
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:docks }
				desc = laamp_base_contract_schemes.3662.desc.business.docks
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:kennels }
				desc = laamp_base_contract_schemes.3662.desc.business.kennels
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:shrine }
				desc = laamp_base_contract_schemes.3662.desc.business.shrine
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:mews }
				desc = laamp_base_contract_schemes.3662.desc.business.mews
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:bridge }
				desc = laamp_base_contract_schemes.3662.desc.business.bridge
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:market }
				desc = laamp_base_contract_schemes.3662.desc.business.market
			}
		}
		desc = boilerplate.paragraph
		first_valid = {
			triggered_desc = {
				trigger = { scope:method = flag:intrigue }
				desc = laamp_base_contract_schemes.3662.desc.method.intrigue
			}
			triggered_desc = {
				trigger = { scope:method = flag:martial }
				desc = laamp_base_contract_schemes.3662.desc.method.martial
			}
			triggered_desc = {
				trigger = { scope:method = flag:prowess }
				desc = laamp_base_contract_schemes.3662.desc.method.prowess
			}
			triggered_desc = {
				trigger = { scope:method = flag:forager }
				desc = laamp_base_contract_schemes.3662.desc.method.forager
			}
			triggered_desc = {
				trigger = { scope:method = flag:thief }
				desc = laamp_base_contract_schemes.3662.desc.method.thief
			}
			triggered_desc = {
				trigger = { scope:method = flag:huntperson }
				desc = laamp_base_contract_schemes.3662.desc.method.huntperson
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:kenneler
					scope:business_type = flag:winery
				}
				desc = laamp_base_contract_schemes.3662.desc.method.kenneler.poison_barrels
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:kenneler
					scope:business_type = flag:kennels
				}
				desc = laamp_base_contract_schemes.3662.desc.method.kenneler.steal_dogs
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:kenneler
					scope:business_type = flag:mews
				}
				desc = laamp_base_contract_schemes.3662.desc.method.kenneler.dog_on_birds
			}
			triggered_desc = {
				trigger = { scope:method = flag:engineer }
				desc = laamp_base_contract_schemes.3662.desc.method.engineer
			}
			triggered_desc = {
				trigger = { scope:method = flag:haggler }
				desc = laamp_base_contract_schemes.3662.desc.method.haggler
			}
			triggered_desc = {
				trigger = { scope:method = flag:armsman }
				desc = laamp_base_contract_schemes.3662.desc.method.armsman
			}
			triggered_desc = {
				trigger = { scope:method = flag:spoiler }
				desc = laamp_base_contract_schemes.3662.desc.method.spoiler
			}
			triggered_desc = {
				trigger = { scope:method = flag:cook }
				desc = laamp_base_contract_schemes.3662.desc.method.cook
			}
		}
		desc = laamp_base_contract_schemes.3662.desc.outro
	}
	theme = intrigue
	left_portrait = {
		character = scope:officer
		animation = spymaster
	}
	center_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:target
		animation = fear
	}
	lower_left_portrait = scope:employer
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:business_type = flag:fallback }
			reference = alley_night
		}
		override_background = {
			trigger = { scope:business_type = flag:inn_exterior }
			reference = bp1_crossroads_inn
		}
		override_background = {
			trigger = { scope:business_type = flag:relaxing_room }
			reference = relaxing_room
		}
		override_background = {
			trigger = { scope:business_type = flag:winery }
			reference = bp1_wine_cellar
		}
		override_background = {
			trigger = { scope:business_type = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:business_type = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:business_type = flag:kennels }
			reference = ep2_dog_kennels
		}
		override_background = {
			trigger = { scope:business_type = flag:shrine }
			reference = holy_site_generic
		}
		override_background = {
			trigger = { scope:business_type = flag:mews }
			reference = ep2_hunt_falconry_mews
		}
		override_background = {
			trigger = { scope:business_type = flag:bridge }
			reference = ep2_travel_bridge
		}
		override_background = {
			trigger = { scope:business_type = flag:market }
			reference = market
		}

	immediate = { laamp_base_contract_schemes_3661_duel_success_effect = yes }
	
	# Gj gg.
	option = {
		name = laamp_base_contract_schemes.3662.a

		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress here.
		# AI takes this by default, but not if they like the alternative.
		ai_chance = { base = 1 }
	}
	
	# Claim responsibility anyway.
	option = {
		name = laamp_base_contract_schemes.3662.b
		trigger = { scope:secrecy = flag:stealthy }
		
		save_scope_value_as = {
			name = stealth
			value = flag:overt
		}
		show_as_tooltip = { laamp_base_contract_schemes_3661_gallowsbait_give_max_effect = yes }

		stress_impact = {
			honest = major_stress_impact_loss
			sadistic = major_stress_impact_loss
		}
		ai_chance = {
			base = 0
			# Only an honest sadist will do this deliberately.
			modifier = {
				add = 1000
				has_trait = honest
				has_trait = sadistic
			}
		}
	}

	after = {
		hidden_effect = { laamp_base_contract_schemes_3661_gallowsbait_update_effect = yes }
	}
}

#	You failed to destroy something.
laamp_base_contract_schemes.3663 = {
	type = character_event
	title = laamp_base_contract_schemes.3663.t
	window = scheme_failed_event
	desc = {
		desc = laamp_base_contract_schemes.3663.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:business_type = flag:fallback }
				desc = laamp_base_contract_schemes.3663.desc.business.fallback
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:inn_exterior }
				desc = laamp_base_contract_schemes.3663.desc.business.inn_exterior
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:relaxing_room }
				desc = laamp_base_contract_schemes.3663.desc.business.relaxing_room
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:winery }
				desc = laamp_base_contract_schemes.3663.desc.business.winery
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:tavern }
				desc = laamp_base_contract_schemes.3663.desc.business.tavern
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:docks }
				desc = laamp_base_contract_schemes.3663.desc.business.docks
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:kennels }
				desc = laamp_base_contract_schemes.3663.desc.business.kennels
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:shrine }
				desc = laamp_base_contract_schemes.3663.desc.business.shrine
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:mews }
				desc = laamp_base_contract_schemes.3663.desc.business.mews
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:bridge }
				desc = laamp_base_contract_schemes.3663.desc.business.bridge
			}
			triggered_desc = {
				trigger = { scope:business_type = flag:market }
				desc = laamp_base_contract_schemes.3663.desc.business.market
			}
		}
		desc = boilerplate.paragraph
		first_valid = {
			triggered_desc = {
				trigger = { scope:method = flag:intrigue }
				desc = laamp_base_contract_schemes.3663.desc.method.intrigue
			}
			triggered_desc = {
				trigger = { scope:method = flag:martial }
				desc = laamp_base_contract_schemes.3663.desc.method.martial
			}
			triggered_desc = {
				trigger = { scope:method = flag:prowess }
				desc = laamp_base_contract_schemes.3663.desc.method.prowess
			}
			triggered_desc = {
				trigger = { scope:method = flag:forager }
				desc = laamp_base_contract_schemes.3663.desc.method.forager
			}
			triggered_desc = {
				trigger = { scope:method = flag:thief }
				desc = laamp_base_contract_schemes.3663.desc.method.thief
			}
			triggered_desc = {
				trigger = { scope:method = flag:huntperson }
				desc = laamp_base_contract_schemes.3663.desc.method.huntperson
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:kenneler
					scope:business_type = flag:winery
				}
				desc = laamp_base_contract_schemes.3663.desc.method.kenneler.poison_barrels
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:kenneler
					scope:business_type = flag:kennels
				}
				desc = laamp_base_contract_schemes.3663.desc.method.kenneler.steal_dogs
			}
			triggered_desc = {
				trigger = {
					scope:method = flag:kenneler
					scope:business_type = flag:mews
				}
				desc = laamp_base_contract_schemes.3663.desc.method.kenneler.dog_on_birds
			}
			triggered_desc = {
				trigger = { scope:method = flag:engineer }
				desc = laamp_base_contract_schemes.3663.desc.method.engineer
			}
			triggered_desc = {
				trigger = { scope:method = flag:haggler }
				desc = laamp_base_contract_schemes.3663.desc.method.haggler
			}
			triggered_desc = {
				trigger = { scope:method = flag:armsman }
				desc = laamp_base_contract_schemes.3663.desc.method.armsman
			}
			triggered_desc = {
				trigger = { scope:method = flag:spoiler }
				desc = laamp_base_contract_schemes.3663.desc.method.spoiler
			}
			triggered_desc = {
				trigger = { scope:method = flag:cook }
				desc = laamp_base_contract_schemes.3663.desc.method.cook
			}
		}
		desc = laamp_base_contract_schemes.3663.desc.outro
	}
	theme = intrigue
	left_portrait = {
		character = scope:officer
		animation = sword_yield_start
	}
	center_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:target
		animation = rage
	}
	lower_left_portrait = scope:employer
	# Backgrounds indented +1 for easier folding.
		override_background = {
			trigger = { scope:business_type = flag:fallback }
			reference = alley_night
		}
		override_background = {
			trigger = { scope:business_type = flag:inn_exterior }
			reference = bp1_crossroads_inn
		}
		override_background = {
			trigger = { scope:business_type = flag:relaxing_room }
			reference = relaxing_room
		}
		override_background = {
			trigger = { scope:business_type = flag:winery }
			reference = bp1_wine_cellar
		}
		override_background = {
			trigger = { scope:business_type = flag:tavern }
			reference = tavern
		}
		override_background = {
			trigger = { scope:business_type = flag:docks }
			reference = docks
		}
		override_background = {
			trigger = { scope:business_type = flag:kennels }
			reference = ep2_dog_kennels
		}
		override_background = {
			trigger = { scope:business_type = flag:shrine }
			reference = holy_site_generic
		}
		override_background = {
			trigger = { scope:business_type = flag:mews }
			reference = ep2_hunt_falconry_mews
		}
		override_background = {
			trigger = { scope:business_type = flag:bridge }
			reference = ep2_travel_bridge
		}
		override_background = {
			trigger = { scope:business_type = flag:market }
			reference = market
		}

	immediate = { laamp_base_contract_schemes_3661_duel_failure_effect = yes }
	
	# Whoops.
	option = {
		name = laamp_base_contract_schemes.3663.a

		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress here.
		# AI takes this by default, but not if they like the alternative.
		ai_chance = { base = 1 }
	}
	
	# Claim responsibility anyway.
	option = {
		name = laamp_base_contract_schemes.3663.b
		trigger = { scope:secrecy = flag:stealthy }
		
		save_scope_value_as = {
			name = stealth
			value = flag:overt
		}
		show_as_tooltip = { laamp_base_contract_schemes_3661_gallowsbait_give_max_effect = yes }

		stress_impact = {
			honest = major_stress_impact_loss
			sadistic = major_stress_impact_loss
		}
		ai_chance = {
			base = 0
			# Only an honest sadist will do this deliberately.
			modifier = {
				add = 1000
				has_trait = honest
				has_trait = sadistic
			}
		}
	}

	after = {
		hidden_effect = { laamp_base_contract_schemes_3661_gallowsbait_update_effect = yes }
	}
}

##################################################
# Heist from a ruler's treasury
# by Ewan Cowhig Croft
# 3781 - 3900
##################################################

scripted_effect laamp_base_contract_schemes_3781_note_old_rollee_duel_effect = {
	if = {
		limit = { scope:secondary_roll = flag:agent_prowess }
		save_scope_value_as = {
			name = old_secondary_roll
			value = flag:agent_prowess
		}
	}
	else_if = {
		limit = { scope:secondary_roll = flag:agent_intrigue }
		save_scope_value_as = {
			name = old_secondary_roll
			value = flag:agent_intrigue
		}
	}
}

scripted_effect laamp_base_contract_schemes_3781_roll_duel_effect = {
	duel = {
		skill = $SKILL$
		target = scope:employer
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.3781.tt.duel_success.$TYPE$
			root = {
				laamp_base_contract_schemes_3781_duel_success_effect = yes
				trigger_event = laamp_base_contract_schemes.3781
			}
		}
		# Defeat.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			# Cap out our max a bit earlier than we usually would so that there's still some risk for the hyper-skilled.
			min = 10
			desc = laamp_base_contract_schemes.3781.tt.duel_failure.$TYPE$
			root = {
				laamp_base_contract_schemes_3781_duel_failure_effect = yes
				trigger_event = laamp_base_contract_schemes.3781
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_3781_roll_camp_officer_effect = {
	scope:rollee = {
		stress_impact = {
			base = medium_stress_gain
			diligent = minor_stress_impact_loss
			lazy = medium_stress_impact_gain
		}
	}
	custom_tooltip = option_boilerplate.tt.officer_aptitude
	random_list = {
		0 = {
			desc = option_boilerplate.tt.officer_aptitude.success
			laamp_base_contract_schemes_3781_duel_success_effect = yes
			trigger_event = laamp_base_contract_schemes.3781
			# Raw aptitude.
			modifier = {
				add = {
					scope:rollee ?= { add = add_camp_officer_aptitude_value }
					multiply = 20
					min = 5
					max = 95
				}
				always = yes
			}
		}
		0 = {
			desc = option_boilerplate.tt.officer_aptitude.failure
			laamp_base_contract_schemes_3781_duel_failure_effect = yes
			trigger_event = laamp_base_contract_schemes.3781
			# Raw aptitude.
			modifier = {
				add = {
					scope:rollee ?= { add = add_camp_officer_aptitude_value }
					multiply = -20
					min = 5
					max = 95
				}
				always = yes
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_3781_duel_success_effect = {
	# How much wealth have we purloined?
	## Boost our haul.
	increment_variable_effect = {
		VAR = haul_actual
		VAL = var:haul_increment
	}
	## Make sure we cap out out.
	if = {
		limit = { var:haul_actual > var:haul_possible }
		set_variable = {
			name = haul_actual
			value = var:haul_possible
		}
	}
	## Flag all of this to the player.
	custom_tooltip = laamp_base_contract_schemes.3781.tt.increment_haul
	save_scope_value_as = {
		name = result
		value = flag:success
	}
}

scripted_effect laamp_base_contract_schemes_3781_duel_failure_effect = {
	if = {
		limit = { var:heist_failures = 0 }
		custom_tooltip = laamp_base_contract_schemes.3781.tt.foul_warning.increment
	}
	else = {
		show_as_tooltip = {
			rightfully_imprison_character_less_verbose_effect = {
				TARGET = root
				IMPRISONER = scope:employer
			}
		}
		custom_tooltip = laamp_base_contract_schemes.3781.tt.foul_warning.pot_lost
	}
	increment_variable_effect = {
		VAR = heist_failures
		VAL = 1
	}
	save_scope_value_as = {
		name = result
		value = flag:failure
	}
}

#	Looping heist event.
laamp_base_contract_schemes.3781 = {
	type = character_event
	title = laamp_base_contract_schemes.3781.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { var:haul_actual >= var:haul_possible }
				desc = laamp_base_contract_schemes.3781.desc.ending
			}
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:play_intro = flag:roll_clip }
						desc = laamp_base_contract_schemes.3781.desc.intro.yes
					}
				}
				triggered_desc = {
					trigger = { scope:result = flag:success }
					desc = {
						first_valid = {
							triggered_desc = {
								trigger = { scope:method = flag:intrigue }
								desc = laamp_base_contract_schemes.3781.desc.success.method.intrigue
							}
							triggered_desc = {
								trigger = { scope:method = flag:prowess }
								desc = laamp_base_contract_schemes.3781.desc.success.method.prowess
							}
							triggered_desc = {
								trigger = { scope:method = flag:martial }
								desc = laamp_base_contract_schemes.3781.desc.success.method.martial
							}
							triggered_desc = {
								trigger = { scope:method = flag:stewardship }
								desc = laamp_base_contract_schemes.3781.desc.success.method.stewardship
							}
							triggered_desc = {
								trigger = { scope:method = flag:agent_intrigue }
								desc = laamp_base_contract_schemes.3781.desc.success.method.agent_intrigue
							}
							triggered_desc = {
								trigger = { scope:method = flag:agent_prowess }
								desc = laamp_base_contract_schemes.3781.desc.success.method.agent_prowess
							}
							triggered_desc = {
								trigger = { scope:method = flag:master_thief }
								desc = laamp_base_contract_schemes.3781.desc.success.method.master_thief
							}
							triggered_desc = {
								trigger = { scope:method = flag:mos }
								desc = laamp_base_contract_schemes.3781.desc.success.method.mos
							}
							triggered_desc = {
								trigger = { scope:method = flag:stress }
								desc = laamp_base_contract_schemes.3781.desc.success.method.stress
							}
						}
						desc = laamp_base_contract_schemes.3781.desc.cta
					}
				}
				triggered_desc = {
					trigger = { scope:result = flag:failure }
					desc = {
						first_valid = {
							triggered_desc = {
								trigger = { scope:method = flag:intrigue }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.intrigue
							}
							triggered_desc = {
								trigger = { scope:method = flag:prowess }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.prowess
							}
							triggered_desc = {
								trigger = { scope:method = flag:martial }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.martial
							}
							triggered_desc = {
								trigger = { scope:method = flag:stewardship }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.stewardship
							}
							triggered_desc = {
								trigger = { scope:method = flag:agent_intrigue }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.agent_intrigue
							}
							triggered_desc = {
								trigger = { scope:method = flag:agent_prowess }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.agent_prowess
							}
							triggered_desc = {
								trigger = { scope:method = flag:master_thief }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.master_thief
							}
							triggered_desc = {
								trigger = { scope:method = flag:mos }
								desc = laamp_base_contract_schemes.3781.desc.failure.method.mos
							}
							# No stress desc, as that can't fail.
						}
						desc = laamp_base_contract_schemes.3781.desc.cta
					}
				}
			}
		}
	}
	theme = intrigue
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:result = flag:failure }
			animation = stress
		}
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:employer
		triggered_animation = {
			trigger = { scope:result = flag:failure }
			animation = rage
		}
		animation = shock
	}
	#TODO_CD_EP3; refactor this so that the old rollee + their scope:secondary_roll flag is shown here, so that the portrait matches up with the loc, and we only show the next rollee as a small portrait instead.
	left_portrait = {
		character = scope:old_rollee
		triggered_animation = {
			trigger = { scope:old_secondary_roll = flag:agent_prowess }
			animation = marshal
		}
		animation = spymaster
	}
	lower_left_portrait = scope:rollee
	override_background = { reference = corridor_night }

	trigger = {
		var:heist_failures < 2
		has_variable = haul_actual
	}

	on_trigger_fail = { trigger_event = laamp_base_contract_schemes.3783 }

	immediate = {
		# Check whether this is our first go-round on the event.
		if = {
			limit = {
				NOT = { exists = scope:play_intro }
			}
			save_scope_value_as = {
				name = play_intro
				value = flag:roll_clip
			}
			# Plus register our tally.
			save_scope_value_as = {
				name = haul_actual
				value = 0
			}
		}
		else = {
			save_scope_value_as = {
				name = play_intro
				value = flag:clip_rolled
			}
			# Error suppress.
			if = {
				limit = { scope:play_intro = flag:clip_rolled }
				# Do nuthin'.
			}
		}
		# Roll our secondary skill.
		## Remove scope:rollee, so that they're not hanging around inappropriately.
		### Which means first flagging them for loc.
		scope:rollee ?= { save_scope_as = old_rollee }
		### Then voiding them to remove their portrait.
		clear_saved_scope = rollee
		## Now roll.
		random_list = {
			# Prowess.
			100 = {
				save_scope_value_as = {
					name = secondary_roll
					value = flag:prowess
				}
				modifier = {
					add = {
						value = prowess
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:prowess
				}
			}
			# Martial.
			100 = {
				save_scope_value_as = {
					name = secondary_roll
					value = flag:martial
				}
				modifier = {
					add = {
						value = martial
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:martial
				}
			}
			# Stewardship.
			100 = {
				save_scope_value_as = {
					name = secondary_roll
					value = flag:stewardship
				}
				modifier = {
					add = {
						value = stewardship
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:stewardship
				}
			}
			# Agent intrigue.
			100 = {
				trigger = { "list_size(former_agents_list)" >= 1 }
				laamp_base_contract_schemes_3781_note_old_rollee_duel_effect = yes
				save_scope_value_as = {
					name = secondary_roll
					value = flag:agent_intrigue
				}
				ordered_in_list = {
					list = former_agents_list
					order_by = {
						value = intrigue
						multiply = 100
						# Weight down anyone we've just rolled.
						if = {
							limit = { scope:old_rollee ?= this }
							multiply = 0.01
						}
					}
					save_scope_as = rollee
				}
				modifier = {
					add = {
						every_in_list = {
							list = former_agents_list
							add = intrigue
						}
						multiply = 2.5
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:agent_intrigue
				}
			}
			# Agent prowess.
			100 = {
				trigger = { "list_size(former_agents_list)" >= 1 }
				laamp_base_contract_schemes_3781_note_old_rollee_duel_effect = yes
				save_scope_value_as = {
					name = secondary_roll
					value = flag:agent_prowess
				}
				ordered_in_list = {
					list = former_agents_list
					order_by = {
						value = prowess
						multiply = 100
						# Weight down anyone we've just rolled.
						if = {
							limit = { scope:old_rollee ?= this }
							multiply = 0.01
						}
					}
					save_scope_as = rollee
				}
				modifier = {
					add = {
						every_in_list = {
							list = former_agents_list
							add = prowess
						}
						multiply = 2.5
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:agent_prowess
				}
			}
			# Master Thief.
			100 = {
				trigger = {
					court_position:master_thief_camp_officer ?= {
						location = root.location
						is_available_allow_travelling = yes
					}
				}
				save_scope_value_as = {
					name = secondary_roll
					value = flag:master_thief
				}
				court_position:master_thief_camp_officer ?= { save_scope_as = rollee }
				modifier = {
					add = {
						court_position:master_thief_camp_officer ?= { add = "aptitude(master_thief_camp_officer)" }
						multiply = 20
						min = 5
						max = 95
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:master_thief
				}
			}
			# Master of Spoils.
			100 = {
				trigger = {
					court_position:master_of_spoils_camp_officer ?= {
						location = root.location
						is_available_allow_travelling = yes
					}
				}
				save_scope_value_as = {
					name = secondary_roll
					value = flag:master_of_spoils
				}
				court_position:master_of_spoils_camp_officer ?= { save_scope_as = rollee }
				modifier = {
					add = {
						court_position:master_of_spoils_camp_officer ?= { add = "aptitude(master_of_spoils_camp_officer)" }
						multiply = 20
						min = 5
						max = 95
					}
					always = yes
				}
				modifier = {
					factor = 0.01
					exists = scope:secondary_roll
					scope:secondary_roll = flag:master_of_spoils
				}
			}
		}
		# Status report tooltips.
		custom_tooltip = laamp_base_contract_schemes.3781.tt.haul_details
		custom_tooltip = laamp_base_contract_schemes.3781.tt.fouls_remaining
	}

	# Intrigue duel.
	option = {
		name = laamp_base_contract_schemes.3781.a
		trigger = { var:haul_actual < var:haul_possible }
		skill = intrigue

		save_scope_value_as = {
			name = method
			value = flag:intrigue
		}
		laamp_base_contract_schemes_3781_roll_duel_effect = {
			SKILL = intrigue
			TYPE = skill
		}

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = intrigue
				always = yes
			}
		}
	}
	
	# Prowess duel
	option = {
		name = laamp_base_contract_schemes.3781.b
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:prowess 
		}
		skill = prowess

		save_scope_value_as = {
			name = method
			value = flag:prowess
		}
		laamp_base_contract_schemes_3781_roll_duel_effect = {
			SKILL = prowess
			TYPE = skill
		}

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = prowess
				always = yes
			}
		}
	}
	
	# Martial duel.
	option = {
		name = laamp_base_contract_schemes.3781.c
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:martial 
		}
		skill = martial

		save_scope_value_as = {
			name = method
			value = flag:martial
		}
		laamp_base_contract_schemes_3781_roll_duel_effect = {
			SKILL = martial
			TYPE = skill
		}

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = martial
				always = yes
			}
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.3781.d
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:stewardship 
		}
		skill = stewardship

		save_scope_value_as = {
			name = method
			value = flag:stewardship
		}
		laamp_base_contract_schemes_3781_roll_duel_effect = {
			SKILL = stewardship
			TYPE = skill
		}

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = stewardship
				always = yes
			}
		}
	}
	
	# Agent intrigue duel.
	option = {
		name = laamp_base_contract_schemes.3781.e
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:agent_intrigue 
		}
		skill = intrigue

		save_scope_value_as = {
			name = method
			value = flag:agent_intrigue
		}
		scope:rollee = {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
			laamp_base_contract_schemes_3781_roll_duel_effect = {
				SKILL = intrigue
				TYPE = agent
			}
		}

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = scope:rollee.intrigue
				always = yes
			}
		}
	}
	
	# Agent prowess duel.
	option = {
		name = laamp_base_contract_schemes.3781.f
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:agent_prowess 
		}
		skill = prowess

		save_scope_value_as = {
			name = method
			value = flag:agent_prowess
		}
		scope:rollee = {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
			laamp_base_contract_schemes_3781_roll_duel_effect = {
				SKILL = prowess
				TYPE = agent
			}
		}

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = scope:rollee.prowess
				always = yes
			}
		}
	}
	
	# Master Thief aptitude.
	option = {
		name = laamp_base_contract_schemes.3781.g
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:master_thief 
		}
		reason = have_master_thief

		save_scope_value_as = {
			name = method
			value = flag:master_thief
		}
		laamp_base_contract_schemes_3781_roll_camp_officer_effect = yes

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = "aptitude(master_thief_camp_officer)"
					multiply = 4
				}
				always = yes
			}
		}
	}
	
	# Master of Spoils aptitude.
	option = {
		name = laamp_base_contract_schemes.3781.h
		trigger = {
			var:haul_actual < var:haul_possible
			scope:secondary_roll = flag:master_of_spoils 
		}
		reason = have_master_of_spoils

		save_scope_value_as = {
			name = method
			value = flag:mos
		}
		laamp_base_contract_schemes_3781_roll_camp_officer_effect = yes

		# No stress here.
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = "aptitude(master_of_spoils_camp_officer)"
					multiply = 4
				}
				always = yes
			}
		}
	}
	
	# Stress auto-success.
	option = {
		name = laamp_base_contract_schemes.3781.i
		trigger = { var:haul_actual < var:haul_possible }

		save_scope_value_as = {
			name = method
			value = flag:stress
		}
		laamp_base_contract_schemes_3781_duel_success_effect = yes
		trigger_event = laamp_base_contract_schemes.3781

		stress_impact = {
			base = major_stress_gain
			diligent = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			# Low value mods to sync with the low AI weights from other values given above.
			ai_value_modifier = { ai_energy = 0.2 }
		}
	}
	
	# Tap out.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { var:haul_actual >= var:haul_possible }
						desc = laamp_base_contract_schemes.3781.j.stole_everything
					}
					desc = laamp_base_contract_schemes.3781.j
				}
			}
		}

		custom_tooltip = laamp_base_contract_schemes.3781.j.tt.flee_with_earnings
		trigger_event = laamp_base_contract_schemes.3782

		# Only apply stress if we've not got our money's worth by this point.
		if = {
			limit = {
				var:haul_actual <= {
					value = var:haul_possible
					multiply = 0.75
				}
			}
			stress_impact = {
				craven = minor_stress_impact_loss
				brave = medium_stress_impact_gain
			}
		}
		ai_chance = {
			base = 0
			# Low value mods to sync with the low AI weights from other values given above.
			ai_value_modifier = { ai_energy = -0.2 }
			# If you haven't got anything, then you should keep trying.
			modifier = {
				add = -1000
				var:haul_actual <= 0
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_3782_clean_variables_effect = {
	remove_variable = haul_possible
	remove_variable = haul_increment
	remove_variable = haul_actual
	remove_variable = heist_failures
}

#	You've tapped out with your extra gains.
laamp_base_contract_schemes.3782 = {
	type = character_event
	title = laamp_base_contract_schemes.3782.t
	desc = {
		desc = laamp_base_contract_schemes.3782.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:haul_percentage <= -1 }
				desc = laamp_base_contract_schemes.3782.desc.haul_amount.grabbed_everything
			}
			triggered_desc = {
				trigger = { scope:haul_percentage <= -0.6 }
				desc = laamp_base_contract_schemes.3782.desc.haul_amount.grabbed_most
			}
			triggered_desc = {
				trigger = { scope:haul_percentage <= -0.3 }
				desc = laamp_base_contract_schemes.3782.desc.haul_amount.grabbed_lots
			}
			triggered_desc = {
				trigger = { scope:haul_actual = 0 }
				desc = laamp_base_contract_schemes.3782.desc.haul_amount.grabbed_nothing
			}
			desc = laamp_base_contract_schemes.3782.desc.haul_amount.grabbed_some
		}
		triggered_desc = {
			trigger = { scope:haul_actual != 0 }
			desc = laamp_base_contract_schemes.3782.desc.outro
		}
	}
	theme = intrigue
	left_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = corridor_night }

	immediate = {
		# Pay out our winnings.
		if = {
			limit = { var:haul_actual > 0 }
			scope:employer = {
				# First root's gold.
				pay_short_term_gold = {
					target = root
					gold = root.var:haul_actual
				}
				## Whilst reimbursing it, as we'll take a portion of it in a sec.
				hidden_effect = { add_gold = root.var:haul_actual }
				# Now, we do our damage to scope:employer.
				## Ok, how much of our total did we actually nab?
				save_scope_value_as = {
					name = haul_percentage
					value = {
						value = root.var:haul_actual
						divide = root.var:haul_possible
						multiply = -1
					}
				}
				## Deduct our earnings.
				if = {
					limit = { scope:contribution_gold != 0 }
					hidden_effect = {
						add_gold = {
							value = scope:contribution_gold
							multiply = scope:haul_percentage
						}
					}
				}
				if = {
					limit = { scope:contribution_prestige != 0 }
					add_prestige = {
						value = scope:contribution_prestige
						multiply = scope:haul_percentage
						# Slightly devalued vs. actual gold, so we up this a bit.
						multiply = 2
					}
				}
				if = {
					limit = { scope:contribution_piety != 0 }
					add_piety = {
						value = scope:contribution_piety
						multiply = scope:haul_percentage
						# Slightly devalued vs. actual gold, so we up this a bit.
						multiply = 2
					}
				}
			}
		}
		# Serve up your gallowsbait.
		save_scope_value_as = {
			name = gallowsbait_xp
			value = {
				value = var:haul_actual
				divide = 25
				ceiling = yes
			}
		}
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = thief
			XP_MAX = scope:gallowsbait_xp
			XP_MIN = scope:gallowsbait_xp
		}
	}

	# Heh, now let's sell this loot...
	option = {
		name = laamp_base_contract_schemes.3782.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}

	# Clean up our variables.
	after = { laamp_base_contract_schemes_3782_clean_variables_effect = yes }
}

#	You are caught, and your gains are lost.
laamp_base_contract_schemes.3783 = {
	type = character_event
	title = laamp_base_contract_schemes.3783.t
	desc = {
		desc = laamp_base_contract_schemes.3783.desc.intro
		first_valid = {
			triggered_desc = {
				# We're a little looser with this trigger than in the success event since, if you have literally everything, you cannot then fail the rest of the chain.
				trigger = { scope:haul_percentage <= -0.95 }
				desc = laamp_base_contract_schemes.3783.desc.haul_amount.grabbed_everything
			}
			triggered_desc = {
				trigger = { scope:haul_percentage <= -0.6 }
				desc = laamp_base_contract_schemes.3783.desc.haul_amount.grabbed_most
			}
			triggered_desc = {
				trigger = { scope:haul_percentage <= -0.3 }
				desc = laamp_base_contract_schemes.3783.desc.haul_amount.grabbed_lots
			}
			triggered_desc = {
				trigger = { scope:haul_actual = 0 }
				desc = laamp_base_contract_schemes.3783.desc.haul_amount.grabbed_nothing
			}
			desc = laamp_base_contract_schemes.3783.desc.haul_amount.grabbed_some
		}
		desc = laamp_base_contract_schemes.3783.desc.outro
	}
	theme = intrigue
	left_portrait = {
		character = root
		animation = prisondungeon
	}
	right_portrait = {
		character = scope:employer
		animation = spymaster
	}
	override_background = { reference = corridor_night }

	immediate = {
		rightfully_imprison_character_less_verbose_effect = {
			TARGET = root
			IMPRISONER = scope:employer
		}
		if = {
			limit = { scope:haul_actual != 0 }
			custom_tooltip = laamp_base_contract_schemes.3783.tt.haul_lost
		}
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = thief
			XP_MAX = gallowsbait_xp_medium_gain
			XP_MIN = gallowsbait_xp_medium_gain
		}
		# Also, so is everyone who was helping you.
		every_in_list = {
			list = former_agents_list
			save_scope_as = char_temp
			rightfully_imprison_character_less_verbose_effect = {
				TARGET = scope:char_temp
				IMPRISONER = scope:employer
			}
			hidden_effect = {
				reverse_add_opinion = {
					target = scope:employer
					modifier = gallowsbait_scum_opinion
					opinion = -50
				}
			}
		}
	}

	# Damn and blast these infernal walls!
	option = {
		name = laamp_base_contract_schemes.3783.a
		
		custom_tooltip = laamp_base_contract_schemes.3783.a.tt.a_cold_cell_awaits

		stress_impact = { base = medium_stress_gain }
		# No AI here.
	}

	# Clean up our variables.
	after = { laamp_base_contract_schemes_3782_clean_variables_effect = yes }
}













##################################################
# SETUP — LEARNING

##################################################
# Copy texts for a learned ruler (setup)
# by Ewan Cowhig Croft
# 4001 - 4010
##################################################

#	Intro event.
laamp_base_contract_schemes.4001 = {
	orphan = yes
	type = character_event
	title = laamp_base_contract_schemes.4001.t
	desc = laamp_base_contract_schemes.4001.desc
	theme = learning
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	right_portrait = {
		character = scope:employer
		animation = page_flipping
	}
	override_background = { reference = study }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.4001.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scribe
			add_agent_slot = agent_scribe
			add_agent_slot = agent_diplomat
			# Speed.
			add_agent_slot = agent_theologian
			add_agent_slot = agent_justiciar_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.4001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scribe
			add_agent_slot = agent_scribe
			add_agent_slot = agent_scribe
			add_agent_slot = agent_diplomat
			# Speed.
			add_agent_slot = agent_theologian
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.4001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scribe
			# Speed.
			add_agent_slot = agent_theologian
			add_agent_slot = agent_theologian
			add_agent_slot = agent_justiciar_speed
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.4002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.4002.t
	desc = laamp_base_contract_schemes.4002.desc
	theme = learning
	center_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = dismissal
	}
	override_background = { reference = study }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_piety = medium_piety_gain
			add_character_modifier = {
				modifier = laamp_base_4001_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.4003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.4003.t
	desc = laamp_base_contract_schemes.4003.desc
	theme = learning
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = disapproval
	}
	override_background = { reference = study }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_piety = medium_piety_loss
			add_character_modifier = {
				modifier = laamp_base_4001_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Help settle a local theological argument (setup)
# by Ewan Cowhig Croft
# 4011 - 4040
##################################################

#	Intro event.
laamp_base_contract_schemes.4011 = {
	orphan = yes
	type = character_event
	title = laamp_base_contract_schemes.4011.t
	desc = laamp_base_contract_schemes.4011.desc
	theme = learning
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:employer
		animation = personality_rational
	}
	lower_right_portrait = scope:chaplain
	override_background = { reference = council_chamber }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			cp:councillor_court_chaplain = { save_scope_as = chaplain }
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.4011.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_theologian_success
			# Speed.
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.4011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_theologian_success
			add_agent_slot = agent_theologian_success
			# Speed.
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.4011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_cleric
			# Speed.
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_socialite
			add_agent_slot = agent_herald
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.4012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.4012.t
	desc = laamp_base_contract_schemes.4012.desc
	theme = learning
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = council_chamber }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = { add_piety = major_piety_gain }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4012.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.4013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.4013.t
	desc = laamp_base_contract_schemes.4013.desc
	theme = learning
	center_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = alley_day }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = { add_piety = medium_piety_loss }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4013.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Create a work of learning for a ruler (setup)
# by Ewan Cowhig Croft
# 4021 - 4030
##################################################

#	Intro event.
laamp_base_contract_schemes.4021 = {
	orphan = yes
	type = character_event
	title = laamp_base_contract_schemes.4021.t
	desc = laamp_base_contract_schemes.4021.desc
	theme = learning
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:employer
		animation = eccentric
	}
	override_background = { reference = corridor_day }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.4021.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scribe
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_tutor
			# Speed.
			add_agent_slot = agent_supplier
			add_agent_slot = agent_theologian
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.4021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scribe
			add_agent_slot = agent_scribe
			add_agent_slot = agent_diplomat
			add_agent_slot = agent_tutor
			# Speed.
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.4021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scribe
			# Speed.
			add_agent_slot = agent_supplier
			add_agent_slot = agent_theologian
			add_agent_slot = agent_theologian
			add_agent_slot = agent_cleric
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.4022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.4022.t
	desc = laamp_base_contract_schemes.4022.desc
	theme = learning
	center_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = page_flipping
	}
	override_background = { reference = study }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_4021_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4022.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.4023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.4023.t
	desc = laamp_base_contract_schemes.4023.desc
	theme = learning
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = stressed_teacher
	}
	override_background = { reference = study }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_4021_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4023.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Solicit Charity (setup)
# by Ewan Cowhig Croft
# 4031 - 4040
##################################################

#	Intro event.
laamp_base_contract_schemes.4031 = {
	type = character_event
	title = laamp_base_contract_schemes.4031.t
	desc = laamp_base_contract_schemes.4031.desc
	theme = learning
	left_portrait = {
		character = root
		animation = beg
	}
	right_portrait = {
		character = scope:employer
		animation = dismissal
	}
	override_background = { reference = throne_room }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.4031.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_shill
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.4031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_cleric_success
			add_agent_slot = agent_shill
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.4031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_cleric_success
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.4032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.4032.t
	desc = laamp_base_contract_schemes.4032.desc
	theme = learning
	center_portrait = {
		character = root
		animation = prayer
	}
	right_portrait = {
		character = scope:employer
		animation = bribing
	}
	override_background = { reference = relaxing_room }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			# Invert piety results if the faith priorities greed.
			if = {
				limit = {
					faith = { trait_is_virtue = greedy }
				}
				add_piety = medium_piety_loss
			}
			# Exacerbate them if the faith prioritise charity.
			else_if = {
				limit = {
					faith = { trait_is_virtue = generous }
				}
				add_piety = major_piety_loss
			}
			# Otherwise we assume charity is just vaguely a good thing.
			else = { add_piety = medium_piety_gain }
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.4033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.4033.t
	desc = laamp_base_contract_schemes.4033.desc
	theme = learning
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = sitting_room }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			# Invert piety results if the faith priorities greed.
			if = {
				limit = {
					faith = { trait_is_virtue = greedy }
				}
				add_piety = medium_piety_gain
			}
			# Exacerbate them if the faith prioritise charity.
			else_if = {
				limit = {
					faith = { trait_is_virtue = generous }
				}
				add_piety = major_piety_gain
			}
			# Otherwise we assume charity is just vaguely a good thing.
			else = { add_piety = medium_piety_loss }
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Sell bogus relics (setup)
# by Ewan Cowhig Croft
# 4041 - 4050
##################################################

#	Intro event.
laamp_base_contract_schemes.4041 = {
	type = character_event
	title = laamp_base_contract_schemes.4041.t
	desc = laamp_base_contract_schemes.4041.desc
	theme = learning
	left_portrait = {
		character = root
		animation = personality_content
	}
	right_portrait = {
		character = scope:employer
		animation = personality_cynical
	}
	override_background = { reference = study }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.4041.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_thief
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_cleric
			add_agent_slot = agent_theologian
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.4041.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_shill
			add_agent_slot = agent_thief
			add_agent_slot = agent_thief
			# Speed.
			add_agent_slot = agent_cleric
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.4041.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			# Speed.
			add_agent_slot = agent_cleric
			add_agent_slot = agent_cleric
			add_agent_slot = agent_theologian
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.4042 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.4042.t
	desc = laamp_base_contract_schemes.4042.desc
	theme = learning
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = relaxing_room }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_4041_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4042.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.4043 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.4043.t
	desc = laamp_base_contract_schemes.4043.desc
	theme = learning
	center_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:employer
		animation = personality_vengeful
	}
	override_background = { reference = corridor_day }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_4041_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.4043.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = yes
	}
}











##################################################
# SETUP — PROWESS

##################################################
# Hunt in the wilds (setup)
# by Ewan Cowhig Croft
# 5001 - 5010
##################################################

#	Intro event.
laamp_base_contract_schemes.5001 = {
	type = character_event
	title = laamp_base_contract_schemes.5001.t
	desc = laamp_base_contract_schemes.5001.desc
	theme = martial
	left_portrait = {
		character = root
		animation = hunting_horn
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	override_background = { reference = wilderness }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
		scope:employer = {
			select_thriving_predator_animal_effect = { LOCATION = scope:employer.capital_county.title_province }
		}
		scope:employer = {
			select_thriving_predator_animal_effect = { LOCATION = scope:employer.capital_county.title_province }
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.5001.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scout
			add_agent_slot = agent_outrider
			add_agent_slot = agent_ambusher
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_wrangler_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.5001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scout
			add_agent_slot = agent_scout
			add_agent_slot = agent_outrider
			add_agent_slot = agent_ambusher
			# Speed.
			add_agent_slot = agent_tracker
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.5001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_scout
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_tracker
			add_agent_slot = agent_wrangler_speed
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.5002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5002.t
	desc = laamp_base_contract_schemes.5002.desc
	theme = martial
	center_portrait = {
		character = root
		scripted_animation = bow_drawn
	}
	lower_left_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		# Clean up variables.
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_5001_success_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= {
			end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded
		
		scope:scheme ?= {
			end_scheme = yes
		}

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
	
	after = {
		scope:employer = { remove_variable = animal_type_event }
	}
}

#	Failure event.
laamp_base_contract_schemes.5003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5003.t
	desc = laamp_base_contract_schemes.5003.desc
	theme = martial
	center_portrait = {
		character = root
		animation = loss_1
	}
	right_portrait = {
		character = scope:employer
		animation = disbelief
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		# Clean up variables.
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_5001_failure_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded
		
		scope:scheme ?= {
			end_scheme = yes
		}

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
	
	after = {
		scope:employer = { remove_variable = animal_type_event }
	}
}

##################################################
# Guard merchant properties (setup)
# by Ewan Cowhig Croft
# 5011 - 5050
##################################################

#	Intro event.
laamp_base_contract_schemes.5011 = {
	type = character_event
	title = laamp_base_contract_schemes.5011.t
	desc = laamp_base_contract_schemes.5011.desc
	theme = martial
	left_portrait = {
		character = root
		animation = boredom
	}
	right_portrait = {
		character = scope:employer
		animation = personality_cynical
	}
	override_background = { reference = alley_night }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.5011.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.5011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_outcast
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.5011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.5012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5012.t
	desc = laamp_base_contract_schemes.5012.desc
	theme = martial
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = happiness
	}
	override_background = { reference = alley_day }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_5011_success_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5012.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.5013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5013.t
	desc = laamp_base_contract_schemes.5013.desc
	theme = martial
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = burning_building }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_5011_failure_employer_modifier
						years = 10
					}
				}
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5013.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Guard a local ruler at a minor event (setup)
# by Ewan Cowhig Croft
# 5021 - 5030
##################################################

#	Intro event.
laamp_base_contract_schemes.5021 = {
	type = character_event
	title = laamp_base_contract_schemes.5021.t
	desc = laamp_base_contract_schemes.5021.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:employer
		animation = spymaster
	}
	override_background = { reference = corridor_day }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.5021.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bodyguard
			add_agent_slot = agent_bodyguard
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.5021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bodyguard
			add_agent_slot = agent_bodyguard
			add_agent_slot = agent_bodyguard
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.5021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_bodyguard
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_socialite
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.5022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5022.t
	desc = laamp_base_contract_schemes.5022.desc
	theme = martial
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = happiness
	}
	override_background = { reference = corridor_night }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_5021_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5022.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.5023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5023.t
	desc = laamp_base_contract_schemes.5023.desc
	theme = martial
	center_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:employer
		animation = fear
	}
	override_background = { reference = corridor_night }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_5021_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5023.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Go rustling (setup)
# by Ewan Cowhig Croft
# 5031 - 5040
##################################################

#	Intro event.
laamp_base_contract_schemes.5031 = {
	type = character_event
	title = laamp_base_contract_schemes.5031.t
	desc = laamp_base_contract_schemes.5031.desc
	theme = martial
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:employer
		animation = personality_honorable
	}
	override_background = { reference = wilderness }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	orphan = yes

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.5031.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_wrangler
			add_agent_slot = agent_wrangler
			add_agent_slot = agent_outrider
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_planner
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.5031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_wrangler
			add_agent_slot = agent_wrangler
			add_agent_slot = agent_outrider
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.5031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_wrangler
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_planner
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.5032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5032.t
	desc = laamp_base_contract_schemes.5032.desc
	theme = martial
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = fear
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = medium_prestige_loss
			add_character_modifier = {
				modifier = laamp_base_5031_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.5033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5033.t
	desc = laamp_base_contract_schemes.5033.desc
	theme = martial
	center_portrait = {
		character = root
		animation = sword_yield_start
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = minor_prestige_gain
			add_character_modifier = {
				modifier = laamp_base_5031_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

scripted_effect laamp_base_contract_schemes_5034_organise_travel_destinations_2_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		on_arrival_event = laamp_base_contract_schemes.5661
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.5035
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_5034_organise_travel_destinations_3_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		on_arrival_event = laamp_base_contract_schemes.5661
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.5035
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_5034_organise_travel_destinations_4_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		destination = scope:destination_4.title_province
		on_arrival_event = laamp_base_contract_schemes.5661
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.5035
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_5034_organise_travel_destinations_5_effect = {
	start_travel_plan = {
		destination = scope:destination_1.title_province
		destination = scope:destination_2.title_province
		destination = scope:destination_3.title_province
		destination = scope:destination_4.title_province
		destination = scope:destination_5.title_province
		on_arrival_event = laamp_base_contract_schemes.5661
		travel_with_domicile = $DOMICILE$
		return_trip = $RETURN$
		on_travel_planner_cancel_event = laamp_base_contract_schemes.5035
		players_use_planner = no
		on_arrival_destinations = $EVENT_FIRE$
	}
}

scripted_effect laamp_base_contract_schemes_5034_append_fresh_destination_effect = {
	ordered_sub_realm_county = {
		order_by = development_level
		limit = {
			trigger_if = {
				# The AI can go w/e, but make sure we get a rational distance for the player.
				limit = {
					root = { is_ai = no }
				}
				NOT = { is_in_list = destinations_list }
				save_temporary_scope_as = destination_temp
				any_in_list = {
					list = destinations_list
					title_province = { "squared_distance(scope:destination_temp.title_province)" <= squared_distance_medium }
				}
			}
			trigger_else = {
				NOT = { is_in_list = destinations_list }
			}
		}
		alternative_limit = {
			NOT = { is_in_list = destinations_list }
		}
		add_to_list = destinations_list
	}
}

#	Travel set-up event.
laamp_base_contract_schemes.5034 = {
	type = character_event
	title = laamp_base_contract_schemes.5034.t
	desc = laamp_base_contract_schemes.5034.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:employer
		animation = shock
	}
	override_background = { reference = bedchamber }

	immediate = {
		# Pick our destinations.
		## First just assemble a bunch of 'em.
		scope:employer = {
			ordered_sub_realm_county = {
				order_by = development_level
				add_to_list = destinations_list
			}
			# Counts get +1.
			if = {
				limit = { highest_held_title_tier >= tier_county }
				laamp_base_contract_schemes_5034_append_fresh_destination_effect = yes
			}
			# Dukes get +2.
			if = {
				limit = {
					highest_held_title_tier >= tier_duchy
					sub_realm_size >= 3
				}
				laamp_base_contract_schemes_5034_append_fresh_destination_effect = yes
			}
			# Kings get +3.
			if = {
				limit = {
					highest_held_title_tier >= tier_kingdom
					sub_realm_size >= 4
				}
				laamp_base_contract_schemes_5034_append_fresh_destination_effect = yes
			}
			# Emperors get +4.
			if = {
				limit = {
					highest_held_title_tier >= tier_empire
					sub_realm_size >= 5
				}
				laamp_base_contract_schemes_5034_append_fresh_destination_effect = yes
			}
		}
		## Then assemble them as actual destinations.
		ordered_in_list = {
			list = destinations_list
			order_by = {
				title_province = { value = "squared_distance(root.location)" }
				multiply = -1
			}
			max = "list_size(destinations_list)"
			check_range_bounds = no
			if = {
				limit = {
					NOT = { exists = scope:destination_1 }
				}
				save_scope_as = destination_1
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounter_max
						VAL = 1
					}
				}
			}
			else_if = {
				limit = {
					NOT = {
						this = scope:destination_1
						exists = scope:destination_2
					}
				}
				save_scope_as = destination_2
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounter_max
						VAL = 1
					}
				}
			}
			else_if = {
				limit = {
					"list_size(preferable_counties_list)" >= 3
					NOT = {
						this = scope:destination_1
						this = scope:destination_2
						exists = scope:destination_3
					}
				}
				save_scope_as = destination_3
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounter_max
						VAL = 1
					}
				}
			}
			else_if = {
				limit = {
					"list_size(preferable_counties_list)" >= 4
					NOT = {
						this = scope:destination_1
						this = scope:destination_2
						this = scope:destination_3
						exists = scope:destination_4
					}
				}
				save_scope_as = destination_4
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounter_max
						VAL = 1
					}
				}
			}
			else_if = {
				limit = {
					"list_size(preferable_counties_list)" >= 5
					NOT = {
						this = scope:destination_1
						this = scope:destination_2
						this = scope:destination_3
						this = scope:destination_4
						exists = scope:destination_5
					}
				}
				save_scope_as = destination_5
				scope:task_contract = {
					increment_variable_effect = {
						VAR = encounter_max
						VAL = 1
					}
				}
			}
		}
	}

	# Travel without domicile.
	option = {
		name = laamp_base_contract_schemes.5034.a

		custom_tooltip = travel.stationary_domicile.tt
		switch = {
			trigger = exists
			scope:destination_5 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.5
				laamp_base_contract_schemes_5034_organise_travel_destinations_5_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
			scope:destination_4 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.4
				laamp_base_contract_schemes_5034_organise_travel_destinations_4_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
			scope:destination_3 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.3
				laamp_base_contract_schemes_5034_organise_travel_destinations_3_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
			scope:destination_2 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.2
				laamp_base_contract_schemes_5034_organise_travel_destinations_2_effect = {
					DOMICILE = no
					RETURN = yes
					EVENT_FIRE = all_but_last
				}
			}
		}
		custom_tooltip = laamp_base_contract_schemes.5034.tt.explanation

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 1000 }
	}

	# Travel with domicile.
	option = {
		name = laamp_base_contract_schemes.5034.b

		custom_tooltip = travel.mobile_domicile.tt
		custom_tooltip = laamp_base_contract_schemes.5034.tt.explanation
		switch = {
			trigger = exists
			scope:destination_5 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.5
				laamp_base_contract_schemes_5034_organise_travel_destinations_5_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
			scope:destination_4 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.4
				laamp_base_contract_schemes_5034_organise_travel_destinations_4_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
			scope:destination_3 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.3
				laamp_base_contract_schemes_5034_organise_travel_destinations_3_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
			scope:destination_2 = {
				custom_tooltip = laamp_base_contract_schemes.5034.tt.destination_list.2
				laamp_base_contract_schemes_5034_organise_travel_destinations_2_effect = {
					DOMICILE = yes
					RETURN = no
					EVENT_FIRE = all
				}
			}
		}

		# No stress here.
		# The AI should only choose to travel without their domicile.
		ai_chance = { base = 0 }
	}
}

#	Travel invalidation event.
laamp_base_contract_schemes.5035 = {
	hidden = yes

	trigger = { is_alive = yes }

	immediate = {
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_2001 }
			save_scope_as = task_contract
		}
		send_interface_message = {
			title = contract_invalidated_title
			type = stewardship_contract_scheme_invalidated_message
			right_icon = scope:task_contract.task_contract_employer
			scope:task_contract = { complete_task_contract = failure_standard }
		}
	}
}

##################################################
# Go poaching (setup)
# by Ewan Cowhig Croft
# 5041 - 5050
##################################################

#	Intro event.
laamp_base_contract_schemes.5041 = {
	type = character_event
	title = laamp_base_contract_schemes.5041.t
	desc = laamp_base_contract_schemes.5041.desc
	theme = martial
	left_portrait = {
		character = root
		animation = hunting_knife_start
	}
	right_portrait = {
		character = scope:employer
		animation = personality_greedy
	}
	override_background = { reference = wilderness }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.5041.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_scout
			add_agent_slot = agent_outrider
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_tracker
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.5041.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_ambusher
			add_agent_slot = agent_scout
			add_agent_slot = agent_outrider
			# Speed.
			add_agent_slot = agent_tracker
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.5041.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_ambusher
			# Speed.
			add_agent_slot = agent_tracker
			add_agent_slot = agent_tracker
			add_agent_slot = agent_planner
			add_agent_slot = agent_supplier
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.5042 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5042.t
	desc = laamp_base_contract_schemes.5042.desc
	theme = martial
	center_portrait = {
		character = root
		scripted_animation = bow_drawn
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = medium_prestige_loss
			add_character_modifier = {
				modifier = laamp_base_5041_success_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5042.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_criminal_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.5043 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5043.t
	desc = laamp_base_contract_schemes.5043.desc
	theme = martial
	center_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:employer
		animation = dismissal
	}
	override_background = { reference = wilderness }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = minor_prestige_gain
			add_character_modifier = {
				modifier = laamp_base_5041_failure_employer_modifier
				years = 10
			}
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5043.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_criminal_stress_effect = yes
	}
}

##################################################
# Muggings (setup)
# by Ewan Cowhig Croft
# 5051 - 5060
##################################################

#	Intro event.
laamp_base_contract_schemes.5051 = {
	type = character_event
	title = laamp_base_contract_schemes.5051.t
	desc = laamp_base_contract_schemes.5051.desc
	theme = martial
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:employer
		animation = stress
	}
	override_background = { reference = alley_night }

	immediate = {
		scope:task_contract.task_contract_employer = { save_scope_as = employer }
	}

	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.5051.d
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thug
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_gabbler
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.5051.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_thug
			add_agent_slot = agent_thug
			add_agent_slot = agent_outcast
			# Speed.
			add_agent_slot = agent_footpad
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.5051.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Speed.
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
			add_agent_slot = agent_gabbler
			# Success.
			add_agent_slot = agent_footpad
			# Secrecy.
			add_agent_slot = agent_lookout
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on secrecy agents.
	option = {
		name = laamp_base_contract_schemes.5051.c
		reason = give_me_secrecy_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SECRECY

		scope:scheme = {
			# Secrecy.
			add_agent_slot = agent_lookout
			add_agent_slot = agent_lookout
			add_agent_slot = agent_decoy
			# Success.
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.5052 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5052.t
	desc = laamp_base_contract_schemes.5052.desc
	theme = martial
	center_portrait = {
		character = root
		animation = steward
	}
	right_portrait = {
		character = scope:employer
		animation = fear
	}
	lower_center_portrait = scope:target
	override_background = { reference = alley_night }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# Employer outcome.
		scope:employer = {
			add_stress = major_stress_loss
			capital_county = { change_county_control = major_county_control_loss }
		}
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5052.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.5053 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5053.t
	desc = laamp_base_contract_schemes.5053.desc
	theme = martial
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	lower_center_portrait = scope:target
	override_background = { reference = alley_day }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_stress = major_stress_gain
			capital_county = { change_county_control = medium_county_control_gain }
		}
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.5053.a
		
		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# EXTRA — PROWESS

##################################################
# Go rustling
# by Ewan Cowhig Croft
# 5661 - 5780
##################################################

scripted_effect laamp_base_contract_schemes_5661_duel_win_effect = {
	custom_tooltip = laamp_base_contract_schemes.5661.tt.score_gained
	scope:task_contract = {
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 1
		}
	}
	scope:county_owner = {
		add_opinion = {
			target = root
			modifier = gallowsbait_scum_opinion
			opinion = -40
		}
		if = {
			limit = {
				NOT = { this = scope:employer }
			}
			add_opinion = {
				target = scope:employer
				modifier = respect_opinion
				opinion = -25
			}
		}
	}
	scope:current_county = { change_county_control = major_county_control_loss }
}

scripted_effect laamp_base_contract_schemes_5661_duel_loss_effect = {
	custom_tooltip = laamp_base_contract_schemes.5661.tt.no_score_gain
	reverse_add_opinion = {
		target = scope:county_owner
		modifier = gallowsbait_scum_opinion
		opinion = -20
	}
}

scripted_effect laamp_base_contract_schemes_5661_roll_duel_effect = {
	duel = {
		skill = $SKILL$
		value = scope:duel_diff
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.5661.$OPTION$.tt.success
			send_interface_toast = {
				type = event_generic_good
				title = laamp_base_contract_schemes.5661.$OPTION$.tt.success
				left_icon = scope:county_owner
				laamp_base_contract_schemes_5661_duel_win_effect = yes
			}
		}
		# Defeat.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = laamp_base_contract_schemes.5661.$OPTION$.tt.failure
			send_interface_toast = {
				type = event_generic_bad
				title = laamp_base_contract_schemes.5661.$OPTION$.tt.failure
				left_icon = scope:county_owner
				laamp_base_contract_schemes_5661_duel_loss_effect = yes
			}
		}
	}
}

scripted_effect laamp_base_contract_schemes_5661_officer_aptitude_duel_effect = {
	scope:officer = {
		stress_impact = {
			base = medium_stress_gain
			diligent = minor_stress_impact_loss
			lazy = medium_stress_impact_gain
		}
	}
	custom_tooltip = option_boilerplate.tt.officer_aptitude
	random_list = {
		0 = {
			desc = option_boilerplate.tt.officer_aptitude.success
			laamp_base_contract_schemes_5661_duel_win_effect = yes
			# Raw aptitude.
			modifier = {
				add = {
					scope:officer ?= { add = add_camp_officer_aptitude_value }
					multiply = 20
					min = 5
					max = 95
				}
				always = yes
			}
		}
		0 = {
			desc = option_boilerplate.tt.officer_aptitude.failure
			laamp_base_contract_schemes_5661_duel_loss_effect = yes
			# Raw aptitude.
			modifier = {
				add = {
					scope:officer ?= { add = add_camp_officer_aptitude_value }
					multiply = -20
					min = 5
					max = 95
				}
				always = yes
			}
		}
	}
}

#	You arrive at a rustling target.
laamp_base_contract_schemes.5661 = {
	type = character_event
	title = laamp_base_contract_schemes.5661.t
	desc = {
		first_valid = {
			#EK DISABLED
			#triggered_desc = {
			#	trigger = { scope:current_county = title:c_byzantion }
			#	desc = laamp_base_contract_schemes.5661.desc.intro.constantinople
			#}
			triggered_desc = {
				trigger = {
					location = { terrain = plains }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.plains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = farmlands }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.farmlands
			}
			triggered_desc = {
				trigger = {
					location = { terrain = hills }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.hills
			}
			triggered_desc = {
				trigger = {
					location = { terrain = mountains }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.mountains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = desert }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.desert
			}
			triggered_desc = {
				trigger = {
					location = { terrain = desert_mountains }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.desert_mountains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = oasis }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.oasis
			}
			triggered_desc = {
				trigger = {
					location = { terrain = jungle }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.jungle
			}
			triggered_desc = {
				trigger = {
					location = { terrain = forest }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.forest
			}
			triggered_desc = {
				trigger = {
					location = { terrain = taiga }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.taiga
			}
			triggered_desc = {
				trigger = {
					location = { terrain = wetlands }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.wetlands
			}
			triggered_desc = {
				trigger = {
					location = { terrain = steppe }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.steppe
			}
			triggered_desc = {
				trigger = {
					location = { terrain = floodplains }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.floodplains
			}
			triggered_desc = {
				trigger = {
					location = { terrain = drylands }
				}
				desc = laamp_base_contract_schemes.5661.desc.intro.drylands
			}
		}
		desc = laamp_base_contract_schemes.5661.desc.intro.postamble
		desc = boilerplate.paragraph
		random_valid = {
			desc = laamp_base_contract_schemes.5661.desc.opportunity.01
			desc = laamp_base_contract_schemes.5661.desc.opportunity.02
			desc = laamp_base_contract_schemes.5661.desc.opportunity.03
			desc = laamp_base_contract_schemes.5661.desc.opportunity.04
			desc = laamp_base_contract_schemes.5661.desc.opportunity.05
			desc = laamp_base_contract_schemes.5661.desc.opportunity.06
		}
		desc = laamp_base_contract_schemes.5661.desc.outro
	}
	theme = martial
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:county_owner
		animation = fear
	}
	lower_left_portrait = scope:officer
	override_background = { reference = wilderness }

	immediate = {
		select_local_farm_animal_effect = yes
		# Increment our encounter tally.
		scope:task_contract = {
			increment_variable_effect = {
				VAR = encounter_tally
				VAL = 1
			}
		}
		# Update on our successes.
		custom_tooltip = laamp_base_contract_schemes.5661.tt.encounter_tally
		custom_tooltip = laamp_base_contract_schemes.5661.tt.current_successes
		# Nab some scopes for loc'n'effects.
		location.county = {
			save_scope_as = current_county
			holder = { save_scope_as = county_owner }
		}
		# Try to nab a valid officer.
		## First assembling potential candidates.
		court_position:head_groom_camp_officer ?= {
			if = {
				limit = { is_available = yes }
				add_to_list = available_officers_list
			}
		}
		court_position:huntperson_camp_officer ?= {
			if = {
				limit = { is_available = yes }
				add_to_list = available_officers_list
			}
		}
		court_position:kennelperson_camp_officer ?= {
			if = {
				limit = { is_available = yes }
				add_to_list = available_officers_list
			}
		}
		court_position:master_of_spoils_camp_officer ?= {
			if = {
				limit = { is_available = yes }
				add_to_list = available_officers_list
			}
		}
		## Then getting whoever does their job best.
		ordered_in_list = {
			list = available_officers_list
			order_by = add_camp_officer_aptitude_value
			save_scope_as = officer
		}
		# Remember to set up our duel difficulty!
		save_scope_value_as = {
			name = duel_diff
			value = {
				value = mediocre_skill_rating
				add = scope:employer.highest_held_title_tier
			}
		}
	}

	# Prowess duel.
	option = {
		name = laamp_base_contract_schemes.5661.a
		skill = prowess

		laamp_base_contract_schemes_5661_roll_duel_effect = {
			SKILL = prowess
			OPTION = a
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = prowess
					subtract = scope:duel_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Martial duel.
	option = {
		name = laamp_base_contract_schemes.5661.b
		trigger = { martial >= stewardship }

		laamp_base_contract_schemes_5661_roll_duel_effect = {
			SKILL = martial
			OPTION = b
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = martial
					subtract = scope:duel_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Stewardship duel.
	option = {
		name = laamp_base_contract_schemes.5661.c
		trigger = { stewardship > martial }

		laamp_base_contract_schemes_5661_roll_duel_effect = {
			SKILL = stewardship
			OPTION = c
		}

		# No stress here.
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = stewardship
					subtract = scope:duel_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Officer: groom.
	option = {
		name = laamp_base_contract_schemes.5661.d
		trigger = {
			scope:officer ?= { has_court_position = head_groom_camp_officer }
		}
		reason = have_head_groom

		laamp_base_contract_schemes_5661_officer_aptitude_duel_effect = yes

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:officer ?= { add = "aptitude(head_groom_camp_officer)" }
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Officer: hunter.
	option = {
		name = laamp_base_contract_schemes.5661.e
		trigger = {
			scope:officer ?= { has_court_position = huntperson_camp_officer }
		}
		reason = have_huntperson

		laamp_base_contract_schemes_5661_officer_aptitude_duel_effect = yes

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:officer ?= { add = "aptitude(huntperson_camp_officer)" }
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Officer: kenneler.
	option = {
		name = laamp_base_contract_schemes.5661.f
		trigger = {
			scope:officer ?= { has_court_position = kennelperson_camp_officer }
		}
		reason = have_kennelperson

		laamp_base_contract_schemes_5661_officer_aptitude_duel_effect = yes

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:officer ?= { add = "aptitude(kennelperson_camp_officer)" }
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Officer: spoiler.
	option = {
		name = laamp_base_contract_schemes.5661.g
		trigger = {
			scope:officer ?= { has_court_position = master_of_spoils_camp_officer }
		}
		reason = have_master_of_spoils

		laamp_base_contract_schemes_5661_officer_aptitude_duel_effect = yes

		stress_impact = {
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:officer ?= { add = "aptitude(master_of_spoils_camp_officer)" }
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# You have no valid officers.
	option = {
		name = laamp_base_contract_schemes.5661.h
		trigger = {
			custom_tooltip = {
				text = laamp_base_contract_schemes.5661.h.tt.need_groom_hunter_kenneler_or_spoiler
				always = no
			}
		}
		show_as_unavailable = {
			NOT = { exists = scope:officer }
		}

		# Dummy option to let you know how you _could_ have had an extra option.
	}
	
	# Stress your way through it.
	option = {
		name = laamp_base_contract_schemes.5661.i

		laamp_base_contract_schemes_5661_duel_win_effect = yes

		stress_impact = {
			base = major_stress_gain
			diligent = minor_stress_loss
			lazy = medium_stress_gain
		}
		ai_chance = {
			base = 1
			# Only take this if we're an over-achiever.
			ai_value_modifier = { ai_energy = 2 }
		}
	}

	after = {
		if = {
			limit = { scope:task_contract.var:encounter_tally >= scope:task_contract.var:encounter_max }
			# Did we do good?
			if = {
				limit = { scope:task_contract.var:wins_tally >= 1 }
				trigger_event = laamp_base_contract_schemes.5662
			}
			# Otherwise, we did bad.
			else = { trigger_event = laamp_base_contract_schemes.5663 }
		}
	}
}

#	You have rustled sufficiently.
laamp_base_contract_schemes.5662 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.5662.t
	desc = laamp_base_contract_schemes.5662.desc
	theme = martial
	left_portrait = {
		character = root
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:employer
		animation = rage
	}
	override_background = { reference = throne_room }

	immediate = {
		scope:task_contract = {
			# Did you earn a crit success?
			if = {
				limit = { var:wins_tally >= var:encounter_max }
				complete_task_contract = success_critical
			}
			# Failing that, earn a regular success
			else = {
				complete_task_contract = success_standard
			}
		}
	}

	# Acknowledged.
	option = {
		name = laamp_base_contract_schemes.5662.a

		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}
}

#	Your rustling leaves something to be desired.
laamp_base_contract_schemes.5663 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.5663.t
	desc = laamp_base_contract_schemes.5663.desc
	theme = martial
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:employer
		animation = dismissal
	}
	override_background = { reference = throne_room }

	immediate = {
		scope:task_contract = { complete_task_contract = failure_standard }
	}

	# Acknowledged.
	option = {
		name = laamp_base_contract_schemes.5663.a

		custom_tooltip = laamp_base_contract_schemes.0000.f.contract_concluded

		# No stress, no AI.
	}
}

##################################################
# Muggings
# by Ewan Cowhig Croft
# 5901 - 6000
##################################################

scripted_trigger laamp_base_contract_schemes_5901_valid_victims_trigger = {
	is_healthy = yes
	is_adult = yes
	is_ai = yes
	gold >= @laamp_base_contract_schemes_5901_min_gold_value
	NOR = {
		save_temporary_scope_as = char_temp
		scope:task_contract = {
			is_target_in_variable_list = {
				name = previous_victims_list
				target = scope:char_temp
			}
		}
		liege = root
	}
}

scripted_effect laamp_base_contract_schemes_5901_duel_success_effect = {
	root = {
		send_interface_toast = {
			type = event_generic_good
			title = laamp_base_contract_schemes.5901.$OPTION$.tt.success
			left_icon = scope:victim
			scope:victim = {
				pay_short_term_gold = {
					target = root
					gold = scope:haul
				}
				progress_towards_rival_effect = {
					REASON = rival_mugged_me
					CHARACTER = root
					OPINION = 0
				}
			}
		}
		reverse_add_opinion = {
			target = scope:victim
			modifier = gallowsbait_scum_opinion
			opinion = -50
		}
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = bandit
			XP_MAX = 2
			XP_MIN = 2
		}
	}
}

scripted_effect laamp_base_contract_schemes_5901_duel_failure_effect = {
	root = {
		send_interface_toast = {
			type = event_generic_bad
			title = laamp_base_contract_schemes.5901.$OPTION$.tt.failure
			left_icon = scope:victim
			custom_tooltip = laamp_base_contract_schemes.5901.tt.victim_escapes
			progress_towards_rival_effect = {
				REASON = rival_attempted_to_mug_me
				CHARACTER = root
				OPINION = 0
			}
		}
		reverse_add_opinion = {
			target = scope:victim
			modifier = gallowsbait_scum_opinion
			opinion = -25
		}
		laamp_rewards_apply_criminal_xp_effect = {
			TRACK = bandit
			XP_MAX = 1
			XP_MIN = 1
		}
	}
}

scripted_effect laamp_base_contract_schemes_5901_roll_duel_effect = {
	duel = {
		skill = $SKILL$
		value = $DIFF$
		# Victory!
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 10
			desc = laamp_base_contract_schemes.5901.$OPTION$.tt.success
			laamp_base_contract_schemes_5901_duel_success_effect = { OPTION = $OPTION$ }
		}
		# Defeat.
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 10
			desc = laamp_base_contract_schemes.5901.$OPTION$.tt.failure
			laamp_base_contract_schemes_5901_duel_failure_effect = { OPTION = $OPTION$ }
		}
	}
}

#	You get a bonus mugging of a wealthy char.
laamp_base_contract_schemes.5901 = {
	type = character_event
	title = laamp_base_contract_schemes.5901.t
	desc = {
		random_valid = {
			desc = laamp_base_contract_schemes.5901.desc.intro.1
			desc = laamp_base_contract_schemes.5901.desc.intro.2
			desc = laamp_base_contract_schemes.5901.desc.intro.3
			desc = laamp_base_contract_schemes.5901.desc.intro.4
			desc = laamp_base_contract_schemes.5901.desc.intro.5
		}
		desc = boilerplate.paragraph
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:victim }
				}
				desc = laamp_base_contract_schemes.5901.desc.victim_type.good_relation
			}
			triggered_desc = {
				trigger = {
					has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:victim }
				}
				desc = laamp_base_contract_schemes.5901.desc.victim_type.bad_relation
			}
			triggered_desc = {
				trigger = { is_consort_of = scope:victim }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.consort
			}
			triggered_desc = {
				trigger = { is_close_or_extended_family_of = scope:victim }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.family
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:courtier }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.courtier
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:baron }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.baron
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:baron_courtier }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.baron_courtier
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:traveller }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.traveller
			}
			triggered_desc = {
				trigger = { scope:victim_type = flag:fallback }
				desc = laamp_base_contract_schemes.5901.desc.victim_type.fallback
			}
		}
		desc = boilerplate.paragraph
		random_valid = {
			desc = laamp_base_contract_schemes.5901.desc.outro.1
			desc = laamp_base_contract_schemes.5901.desc.outro.2
			desc = laamp_base_contract_schemes.5901.desc.outro.3
			desc = laamp_base_contract_schemes.5901.desc.outro.4
			desc = laamp_base_contract_schemes.5901.desc.outro.5
		}
	}
	theme = martial
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:victim
		animation = personality_bold
	}
	lower_left_portrait = scope:rollee
	override_background = { reference = alley_night }

	trigger = { scope:scheme.var:special_muggings_tally < scope:scheme.var:special_muggings_max }

	immediate = {
		# Nab our contract.
		random_character_active_contract = {
			limit = { has_task_contract_type = laamp_base_5051 }
			save_scope_as = task_contract
		}
		# Add to our tally.
		scope:scheme = {
			increment_variable_effect = {
				VAR = special_muggings_tally
				VAL = 1
			}
		}
		# Plus, tell the player how many special muggings they're even at.
		custom_tooltip = laamp_base_contract_schemes.5901.tt.muggings_tally_and_max
		# Grab a target.
		## Clearing out prior scopes if necessary.
		clear_saved_scope = victim
		every_in_list = {
			list = potential_chars_list
			remove_from_list = potential_chars_list
		}
		## First put a bunch of people in a big list.
		### Local courtiers.
		scope:target = {
			every_courtier = {
				limit = {
					laamp_base_contract_schemes_5901_valid_victims_trigger = yes
					is_available = yes
				}
				add_to_list = potential_chars_list
				add_to_list = is_courtier_char_list
			}
		}
		### Local barons + their courtiers + travellers.
		scope:target.capital_county.duchy = {
			every_dejure_vassal_title_holder = {
				limit = {
					highest_held_title_tier = tier_barony
					any_liege_or_above = { this = scope:target }
				}
				# Barons.
				if = {
					limit = {
						laamp_base_contract_schemes_1782_valid_target_char_trigger = yes
						is_available = yes
					}
					add_to_list = potential_chars_list
					add_to_list = is_baron_char_list
				}
				# Their courtiers.
				every_courtier = {
					if = {
						limit = {
							laamp_base_contract_schemes_1782_valid_target_char_trigger = yes
							is_available = yes
						}
						add_to_list = potential_chars_list
						add_to_list = is_baron_courtier_char_list
					}
				}
				# Travellers.
				primary_title.title_province = {
					every_character_in_location = {
						limit = {
							laamp_base_contract_schemes_1782_valid_target_char_trigger = yes
							is_travelling = yes
							highest_held_title_tier <= tier_barony
						}
						save_scope_as = potential_chars_list
						add_to_list = is_travelling_char_list
					}
				}
			}
		}
		## Aaaand process them to pick out the one we want.
		random_in_list = {
			list = potential_chars_list
			weight = {
				# Take our wealth as the standard measurement.
				modifier = {
					add = {
						value = gold
						subtract = @laamp_base_contract_schemes_5901_min_gold_value
					}
					always = yes
				}
				# Adjust for traits.
				## Greedy (keeps their money secure)
				modifier = {
					add = -100
					has_trait = greedy
				}
				## Generous (always has some to give away)
				modifier = {
					add = 200
					has_trait = generous
				}
				## Arrogant
				modifier = {
					add = 50
					has_trait = arrogant
				}
				## Humble
				modifier = {
					add = -50
					has_trait = humble
				}
				## Craven
				modifier = {
					add = -100
					has_trait = craven
				}
				## Brave
				modifier = {
					add = 100
					has_trait = brave
				}
			}
			save_scope_as = victim
			# Log them as someone we shouldn't rob again this contract.
			scope:task_contract = {
				add_to_variable_list = {
					name = previous_victims_list
					target = scope:victim
				}
			}
		}
		## If we managed to _not_ grab anyone, then generate someone as a fallback.
		if = {
			limit = {
				NOT = { exists = scope:victim }
			}
			create_character = {
				template = merchant_template
				culture = location.culture
				faith = location.faith
				location = root.location
				save_scope_as = victim
			}
		}
		hidden_effect = {
			scope:victim = {
				if = {
					limit = {
						gold < 50
					}
					add_gold = {
						value = {
							integer_range = {
								min = 50
								max = 100
							}
						}
					}
				}
			}
		}
		# Cool, now that we've got a victim, let's set up some scopes derived from them.
		## See what list they came from for the desc.
		scope:victim = {
			switch = {
				trigger = is_in_list
				is_courtier_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:courtier
					}
				}
				is_baron_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:baron
					}
				}
				is_baron_courtier_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:baron_courtier
					}
				}
				is_travelling_char_list = {
					save_scope_value_as = {
						name = victim_type
						value = flag:traveller
					}
				}
				fallback = {
					save_scope_value_as = {
						name = victim_type
						value = flag:fallback
					}
				}
			}
		}
		## Plus set up how much gold we might be able to purloin from them.
		save_scope_value_as = {
			name = haul
			value = {
				value = scope:victim.gold
				multiply = 0.5
				min = 50
				max = 300
			}
		}
		## Finally, check our skills for the duel diffs.
		save_scope_value_as = {
			name = prowess_diff
			value = {
				add = scope:victim.prowess
				add = highest_held_title_tier
				min = decent_skill_rating
			}
		}
		save_scope_value_as = {
			name = intrigue_diff
			value = {
				add = scope:victim.intrigue
				add = highest_held_title_tier
				min = mediocre_skill_rating
			}
		}
		# Grab a tertiary rollee.
		## Remove any old one we might have.
		clear_saved_scope = rollee
		## Try to nab a new one.
		random_list = {
			100 = {
				trigger = {
					scope:scheme = {
						any_scheme_agent_character = { count >= 1 }
					}
				}
				scope:scheme = {
					ordered_scheme_agent_character = {
						order_by = intrigue
						save_scope_as = rollee
					}
				}
				save_scope_value_as = {
					name = tertiary_roll
					value = flag:agent_intrigue
				}
				scope:scheme = {
					set_variable = {
						name = last_tertiary_roller
						value = flag:agent_intrigue
					}
				}
				modifier = {
					add = -50
					scope:scheme = { var:last_tertiary_roller ?= flag:agent_intrigue  }
				}
			}
			100 = {
				trigger = {
					scope:scheme = {
						any_scheme_agent_character = { count >= 1 }
					}
				}
				scope:scheme = {
					ordered_scheme_agent_character = {
						order_by = prowess
						save_scope_as = rollee
					}
				}
				save_scope_value_as = {
					name = tertiary_roll
					value = flag:agent_prowess
				}
				scope:scheme = {
					set_variable = {
						name = last_tertiary_roller
						value = flag:agent_prowess
					}
				}
				modifier = {
					add = -50
					scope:scheme = { var:last_tertiary_roller ?= flag:agent_prowess }
				}
			}
			100 = {
				trigger = {
					court_position:master_thief_camp_officer ?= { is_available = yes }
				}
				court_position:master_thief_camp_officer = { save_scope_as = rollee }
				save_scope_value_as = {
					name = tertiary_roll
					value = flag:master_thief
				}
				scope:scheme = {
					set_variable = {
						name = last_tertiary_roller
						value = flag:master_thief
					}
				}
				modifier = {
					add = -50
					scope:scheme = { var:last_tertiary_roller ?= flag:master_thief }
				}
			}
		}
	}

	# Prowess duel.
	option = {
		name = laamp_base_contract_schemes.5901.a
		skill = prowess

		laamp_base_contract_schemes_5901_roll_duel_effect = {
			SKILL = prowess
			DIFF = scope:prowess_diff
			OPTION = a
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = prowess
					subtract = scope:prowess_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Intrigue duel.
	option = {
		name = laamp_base_contract_schemes.5901.b
		skill = intrigue

		laamp_base_contract_schemes_5901_roll_duel_effect = {
			SKILL = intrigue
			DIFF = scope:intrigue_diff
			OPTION = b
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = intrigue
					subtract = scope:intrigue_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Agent prowess duel.
	option = {
		name = laamp_base_contract_schemes.5901.c
		trigger = {
			exists = scope:rollee
			scope:tertiary_roll = flag:agent_prowess
		}
		skill = prowess

		scope:rollee = {
			laamp_base_contract_schemes_5901_roll_duel_effect = {
				SKILL = prowess
				DIFF = scope:prowess_diff
				OPTION = c
			}
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = scope:rollee.prowess
					subtract = scope:prowess_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Agent intrigue duel.
	option = {
		name = laamp_base_contract_schemes.5901.d
		trigger = {
			exists = scope:rollee
			scope:tertiary_roll = flag:agent_intrigue
		}
		skill = intrigue

		scope:rollee = {
			laamp_base_contract_schemes_5901_roll_duel_effect = {
				SKILL = intrigue
				DIFF = scope:intrigue_diff
				OPTION = d
			}
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					value = scope:rollee.intrigue
					subtract = scope:intrigue_diff
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Master Thief duel.
	option = {
		name = laamp_base_contract_schemes.5901.e
		trigger = {
			exists = scope:rollee
			scope:tertiary_roll = flag:master_thief
		}
		reason = have_master_thief

		scope:rollee = {
			stress_impact = {
				base = medium_stress_gain
				diligent = minor_stress_impact_loss
				lazy = medium_stress_impact_gain
			}
		}
		custom_tooltip = option_boilerplate.tt.officer_aptitude
		random_list = {
			0 = {
				desc = option_boilerplate.tt.officer_aptitude.success
				laamp_base_contract_schemes_5901_duel_success_effect = { OPTION = e }
				# Raw aptitude.
				modifier = {
					add = {
						scope:rollee ?= { add = add_camp_officer_aptitude_value }
						multiply = 20
						min = 5
						max = 95
					}
					always = yes
				}
			}
			0 = {
				desc = option_boilerplate.tt.officer_aptitude.failure
				laamp_base_contract_schemes_5901_duel_failure_effect = { OPTION = e }
				# Raw aptitude.
				modifier = {
					add = {
						scope:rollee ?= { add = add_camp_officer_aptitude_value }
						multiply = -20
						min = 5
						max = 95
					}
					always = yes
				}
			}
		}

		stress_impact = {
			arbitrary = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				add = {
					scope:officer ?= { add = "aptitude(master_thief_camp_officer)" }
					multiply = 5
				}
				always = yes
			}
		}
	}
	
	# Let the opportunity pass.
	option = {
		name = laamp_base_contract_schemes.5901.f

		custom_tooltip = laamp_base_contract_schemes.5901.f.tt

		stress_impact = {
			just = miniscule_stress_impact_loss
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_honor = 1 }
		}
	}
}












##################################################
# JUSTICAR (all)

##################################################
# Protect the Innocent (Justicar)
# 6001 - 6003
##################################################

#	Intro event.
laamp_base_contract_schemes.6001 = {
	type = character_event
	title = laamp_base_contract_schemes.6001.t
	desc = laamp_base_contract_schemes.6001.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	right_portrait = {
		character = scope:employer
		animation = worry
	}
	override_background = { reference = terrain }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.6001.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_outcast
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.6001.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.6001.c
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.6002 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.6002.t
	desc = laamp_base_contract_schemes.6002.desc
	theme = martial
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:employer
		animation = happiness
	}
	override_background = { reference = alley_day }

	immediate = {
		select_local_animal_effect = { TYPE = dangerous }
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		random_list = {
			67 = {
				scope:scheme.task_contract = { complete_task_contract = success_standard }
			}
			33 = {
				scope:scheme.task_contract = { complete_task_contract = success_critical }
			}
		}
		# Employer outcome.
		scope:employer = {
			add_stress = major_stress_loss
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6002.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.6003 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.6003.t
	desc = laamp_base_contract_schemes.6003.desc
	theme = martial
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = burning_building }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_stress = medium_stress_gain
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6003.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Rescue a Fair Subject (Justicar)
# 6011 - 6013
##################################################

#	Intro event.
laamp_base_contract_schemes.6011 = {
	type = character_event
	title = laamp_base_contract_schemes.6011.t
	desc = laamp_base_contract_schemes.6011.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	right_portrait = {
		character = scope:employer
		animation = worry
	}
	override_background = { reference = army_camp }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:employer = {
			random_dummy_gender_non_combatant_effect = { SCOPE_NAME = dummy_gender }
			random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_gender_soldier }
		}
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.6011.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_outcast
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.6011.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.6011.c
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.6012 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.6012.t
	desc = laamp_base_contract_schemes.6012.desc
	theme = martial
	center_portrait = {
		character = root
		animation = sword_coup_degrace
	}
	right_portrait = {
		character = scope:beautiful_peasant
		animation = ecstasy
	}
	override_background = { reference = ce1_legendary_spring }

	immediate = {
		create_character = {
			location = root.location
			template = beautiful_peasant_character
			gender_female_chance = root_non_combatant_female_chance
			faith = root.location.county.faith
			culture = root.location.county.culture
			dynasty = none
			save_scope_as = beautiful_peasant
		}
		select_local_animal_effect = { TYPE = dangerous }
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		# Employer outcome.
		scope:employer = {
			add_character_modifier = {
				modifier = laamp_base_6012_success_employer_modifier
				years = 10
			}
		}
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6012.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
	
	# I would like to ask her to join me, actually
	option = {
		name = laamp_base_contract_schemes.6012.b
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded
		
		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
		duel = {
			skills = { intrigue diplomacy }
			target = scope:beautiful_peasant
			# You convince them
			70 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.6012.b.tt.success
				send_interface_toast = {
					type = event_generic_good
					title = laamp_base_contract_schemes.6012.b.tt.success
					left_icon = scope:beautiful_peasant
					add_courtier = scope:beautiful_peasant
					scope:employer = {
						add_opinion = {
							target = root
							modifier = annoyed_opinion
							opinion = -10
						}
					}
				}
			}
			# Bye
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = laamp_base_contract_schemes.6012.b.tt.failure
				send_interface_toast = {
					type = event_generic_bad
					title = laamp_base_contract_schemes.6012.b.tt.failure
					left_icon = scope:beautiful_peasant
					scope:beautiful_peasant = {
						add_opinion = {
							target = root
							modifier = insulted_opinion
							opinion = -10
						}
					}							
				}
			}
		}
	}
}

#	Failure event.
laamp_base_contract_schemes.6013 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.6013.t
	desc = laamp_base_contract_schemes.6013.desc
	theme = martial
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = minor_prestige_loss
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6013.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Participate in a Chivalry Play (Justicar)
# 6021 - 6023
##################################################

#	Intro event.
laamp_base_contract_schemes.6021 = {
	type = character_event
	title = laamp_base_contract_schemes.6021.t
	desc = {
		desc = laamp_base_contract_schemes.6021.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:employer_child
				}
				desc = laamp_base_contract_schemes.6021.desc.employer_child
			}
			desc = laamp_base_contract_schemes.6021.desc.random_child
		}
		desc = laamp_base_contract_schemes.6021.desc.outro
	}
	theme = diplomacy
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = eyeroll
		}
		animation = laugh
	}
	right_portrait = {
		character = scope:employer
		animation = personality_compassionate
	}
	override_background = { reference = market }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		random_dummy_gender_effect = yes
		select_local_animal_effect = { TYPE = dangerous }
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
		if = {
			limit = {
				scope:employer = {
					any_child = { age <= 14 }
				}
			}
			scope:employer = {
				random_child = {
					limit = { age <= 14 }
					save_scope_as = employer_child
				}
			}
		}
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.6021.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_shill
			add_agent_slot = agent_poet
			add_agent_slot = agent_musician
			# Speed.
			add_agent_slot = agent_socialite
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.6021.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_poet
			# Speed.
			add_agent_slot = agent_socialite
			add_agent_slot = agent_gabbler
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.6021.c
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_shill
			add_agent_slot = agent_poet
			add_agent_slot = agent_musician
			# Speed.
			add_agent_slot = agent_socialite
			add_agent_slot = agent_gabbler
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.6022 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.6022.t
	desc = laamp_base_contract_schemes.6022.desc
	theme = martial
	center_portrait = {
		character = root
		animation = sword_coup_degrace
	}
	right_portrait = {
		character = scope:employer
		animation = throne_room_applaud_1
	}
	override_background = { reference = market }

	immediate = {
		select_local_animal_effect = { TYPE = dangerous }
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		# Employer outcome.
		scope:employer = {
			if = {
				limit = { contract_employer_can_apply_county_modifier_trigger = yes }
				capital_county = {
					add_county_modifier = {
						modifier = laamp_base_6021_success_employer_modifier
						years = 10
					}
				}
			}
		}
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6022.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.6023 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.6023.t
	desc = laamp_base_contract_schemes.6023.desc
	theme = martial
	center_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:employer
		animation = disapproval
	}

	immediate = {
		select_local_animal_effect = { TYPE = dangerous }
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = minor_prestige_loss
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6023.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}

##################################################
# Do a Pas d'Armes (Justicar)
# 6031 - 6033
##################################################

#	Intro event.
laamp_base_contract_schemes.6031 = {
	type = character_event
	title = laamp_base_contract_schemes.6031.t
	desc = laamp_base_contract_schemes.6031.desc
	theme = martial
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	right_portrait = {
		character = scope:employer
		animation = happiness
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:employer = {
			get_quirk_character_effect = yes
		}
		scope:task_contract.task_contract_employer = {
			save_scope_as = employer
			save_scope_as = bg_override_char
		}
	}

	# Focus on success chance agents.
	option = {
		name = laamp_base_contract_schemes.6031.a
		reason = give_me_success_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SUCCESS

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_outcast
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Focus on speedy agents.
	option = {
		name = laamp_base_contract_schemes.6031.b
		reason = give_me_speed_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_SPEED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always picks the balanced config.
	}
	
	# Go for a balanced agent mix.
	option = {
		name = laamp_base_contract_schemes.6031.c
		reason = give_me_balanced_agents
		flavor = EVENT_WINDOW_OPTION_AGENTS_BALANCED

		scope:scheme = {
			# Success.
			add_agent_slot = agent_muscle
			add_agent_slot = agent_muscle
			add_agent_slot = agent_thug
			# Speed.
			add_agent_slot = agent_lookout_speed
			add_agent_slot = agent_footpad
		}

		# No stress, we're just selecting our starter batch.
		# AI always selects balanced agents.
		ai_chance = { base = 1000 }
	}

	# Now show us the panel.
	after = {
		open_view = {
			view = intrigue_window
			player = root
		}
	}
}

#	Success event.
laamp_base_contract_schemes.6032 = {
	type = character_event
	window = scheme_successful_event
	title = laamp_base_contract_schemes.6032.t
	desc = laamp_base_contract_schemes.6032.desc
	theme = martial
	center_portrait = {
		character = root
		animation = celebrate_spear
	}
	right_portrait = {
		character = scope:employer
		animation = admiration
	}
	override_background = { reference = ep2_travel_bridge }

	immediate = {
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_soldier }	
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		# Employer outcome.
		scope:employer = {
			add_prestige = minor_prestige_gain
		}
		scope:scheme.task_contract = { complete_task_contract = success_standard }
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6032.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_success_stress_effect = yes
	}
}

#	Failure event.
laamp_base_contract_schemes.6033 = {
	type = character_event
	window = scheme_failed_event
	title = laamp_base_contract_schemes.6033.t
	desc = laamp_base_contract_schemes.6033.desc
	theme = martial
	center_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:employer
		animation = anger
	}
	override_background = { reference = ep2_travel_bridge }

	immediate = {
		laamp_base_contract_schemes_set_up_outcome_immediate_effect = yes
		scope:scheme.task_contract = { complete_task_contract = failure_standard }
		# Employer outcome.
		scope:employer = {
			add_prestige = minor_prestige_loss
		}
		# And wrap things up.
		scope:scheme ?= { end_scheme = yes }
	}

	# Acknowledge.
	option = {
		name = laamp_base_contract_schemes.6033.a
		flavor = laamp_base_contract_schemes.0000.f.contract_concluded

		laamp_base_contract_schemes_acknowledge_failure_stress_effect = yes
	}
}











##################################################
# MAINTENANCE

# 9901+ reserved for... whatever comes up.
