﻿##################################################
# INFO
# For laamp contracts that are broadly applicable: that is, they should be able to trigger virtually anywhere and with a minimum of triggers.
# The idea is that any given laamp led by a character skilled in any one thing should always be viable — maybe through crime, maybe by demeaning themselves, but they should always have some contracts around to work with.
##################################################



##################################################
# GROUPS (for populate_task_contracts_for_area)
# 
# laamp_contracts_criminal_group
# laamp_contracts_diplomacy_group
# laamp_contracts_hireling_group
# laamp_contracts_hunting_group
# laamp_contracts_intrigue_group
# laamp_contracts_learning_group
# laamp_contracts_martial_group
# laamp_contracts_stewardship_group
# laamp_contracts_justicar_group
# 

##################################################
# #Diplo Contracts
# laamp_base_0001		Regale court with stories
# laamp_base_0011		Improve ruler's reputation
# laamp_base_0021		Hobnob with local ruler
# laamp_base_0031		Paid Mediator
# laamp_base_0041		Confidence trickster
#
# #Martial Contracts
# laamp_base_1001		Hunt criminals
# laamp_base_1011		Act as hired muscle
# laamp_base_1021		Help train local MaA
# laamp_base_1031		Garrison service
# laamp_base_1041		Ambush travellers
#
# #Stewardship Contracts
# laamp_base_2001		Collect taxes for a third party
# laamp_base_2011		Perform a census
# laamp_base_2021		Help construct a building
# laamp_base_2031		Settle an administrative boundary dispute
# laamp_base_2041		Collect fake taxes
#
# #Intrigue Contracts
# laamp_base_3001		Provide intelligence from your trips
# laamp_base_3011		Murder a character's rival
# laamp_base_3021		Abduct a character's rival
# laamp_base_3031		Attack the property of a character's rival
# laamp_base_3041		Heist from a ruler's treasury
#
# #Learning Contracts
# laamp_base_4001		Transcribe texts for a learned ruler
# laamp_base_4011		Help settle theological arguments
# laamp_base_4021		Create a work of learning for a ruler
# laamp_base_4031		Solicit Charity
# laamp_base_4041		Sell bogus relics
# laamp_base_4100		Act as a tutor for ruler's child
#
# #Prowess Contracts
# laamp_base_5001		Hunt in the wilds
# laamp_base_5011		Guard merchant properties
# laamp_base_5021		Guard a local ruler at a minor event
# laamp_base_5031		Go rustling
# laamp_base_5041		Go poaching
#
# #Justicar Contracts
# laamp_base_6001		Protect the innocent
# laamp_base_6011		Rescue a Fair Non-Combatant Gender
# laamp_base_6021		Participate in a Chivalry Play
# laamp_base_6031		Do a Pass d'Armes
##################################################










##################################################
# DIPLO CONTRACTS

# Regale court with stories
laamp_base_0001 = {
	group = laamp_contracts_diplomacy_group
	icon = "gfx/interface/icons/scheme_types/diplomacy.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_diplomacy_value
		add = laamp_contracts_weight_up_diplomacy_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that like to hear from strangers.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = eccentric }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't have time for riff-raff.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_0001_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.0001
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_critical_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Improve ruler's reputation
laamp_base_0011 = {
	group = laamp_contracts_diplomacy_group
	icon = "gfx/interface/icons/scheme_types/diplomacy.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_diplomacy_value
		add = laamp_contracts_weight_up_diplomacy_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits most likely to suffer from reputational damage generally.
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = sadistic }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't acknowledge fault.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		scope:employer = {
			# Doesn't feel right coming from anyone too famous, even if they're currently hated.
			prestige_level <= high_prestige_level
			OR = {
				# Anyone who could use a little more political capital.
				prestige <= 500
				# Or who's got a bit of a... reputation.
				strife_opinion >= 1
				tyranny >= 1
				# And any important unlikeable characters in their realm that indicate they might be a bit of a prick.
				any_relation = {
					type = rival
					liege ?= prev
				}
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_0011_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.0011
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Hobnob with local ruler
laamp_base_0021 = {
	group = laamp_contracts_diplomacy_group
	icon = "gfx/interface/icons/scheme_types/diplomacy.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_diplomacy_value
		add = laamp_contracts_weight_up_diplomacy_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Actively sociable traits.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = humble }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't have time for riff-raff.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
		scope:employer = {
			NOR = {
				any_relation = { type = friend }
				any_relation = { type = lover }
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_0021_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.0021
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_critical_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Paid Mediator
laamp_base_0031 = {
	group = laamp_contracts_diplomacy_group
	icon = "gfx/interface/icons/scheme_types/diplomacy.dds"

	travel = no
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_diplomacy_value
		add = laamp_contracts_weight_up_diplomacy_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that like to outsource.
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that prefer a hand-on approach.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		scope:employer = {
			AND = {
				highest_held_title_tier >= tier_county
				sub_realm_size >= 3
			}
			NOR = {
				has_trait = arrogant
				has_trait = arbitrary
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the travel.
		task_contract_taker ?= {
			trigger_event = laamp_base_contract_schemes.0034
			set_variable = {
				name = laamp_base_0031_tally
				value = 0
			}
		}
	}
	on_completed = {
		# Clean up our variables & such.
		task_contract_taker = {
			remove_variable ?= laamp_base_0031_tally
			remove_character_flag = laamp_base_0031_contract_used_diplomacy
			remove_character_flag = laamp_base_0031_contract_used_martial
			remove_character_flag = laamp_base_0031_contract_used_stewardship
			remove_character_flag = laamp_base_0031_contract_used_intrigue
			remove_character_flag = laamp_base_0031_contract_used_learning
			remove_character_flag = laamp_base_0031_contract_used_prowess
		}
	}
	on_invalidated = {
		# Clean up our variables & such.
		task_contract_taker = {
			remove_variable ?= laamp_base_0031_tally
			remove_character_flag = laamp_base_0031_contract_used_diplomacy
			remove_character_flag = laamp_base_0031_contract_used_martial
			remove_character_flag = laamp_base_0031_contract_used_stewardship
			remove_character_flag = laamp_base_0031_contract_used_intrigue
			remove_character_flag = laamp_base_0031_contract_used_learning
			remove_character_flag = laamp_base_0031_contract_used_prowess
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_critical_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Confidence trickster
laamp_base_0041 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/diplomacy.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_diplomacy_value
		add = laamp_contracts_weight_up_diplomacy_slight_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Credulous traits.
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = honest }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = eccentric }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that are naturally suspicious.
				if = {
					limit = { has_trait = cynical }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				## Paranoid is already excluded from even vaguely triggering this.
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		scope:employer = {
			NOT = { has_trait = paranoid }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_0041_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.0041
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Criminal Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_criminal_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}










##################################################
# MARTIAL & PROWESS CONTRACTS

# Hunt criminals
laamp_base_1001 = {
	group = laamp_contracts_justicar_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_martial_value
		add = laamp_contracts_weight_up_martial_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that are happy to outsource or care largely for results.
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that prefer a personal touch.
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = sadistic }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		## Won't resort to this.
		laamp_task_contract_employer_would_resort_to_violence_trigger = yes
		## Effects require a capital county.
		scope:employer.capital_county ?= {
			# Aaaand we need to have at least three duchies in our de jure kingdom.
			kingdom = {
				any_in_de_jure_hierarchy = {
					continue = { tier >= tier_duchy }
					tier = tier_duchy
					count >= 3
				}
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
		# Specific flavour triggers.
		## Effects require a capital county.
		exists = root.task_contract_employer.capital_county
		## Make sure that if we've got our recidivist, then they've not died at any time other than when they're _specifically_ allowed to.
		OR = {
			NOT = { has_variable = recidivist }
			var:recidivist ?= {
				OR = {
					is_alive = yes
					root = { has_variable = duel_engaged }
				}
				is_imprisoned = no
			}
		}
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.1004 }
		# Track our score/encounters.
		increment_variable_effect = {
			VAR = encounters_tally
			VAL = 0
		}
		# & numbers of chars checked for loc.
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 0
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_major_gain
						XP_MIN = knight_errant_xp_major_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		failure_recruitment = {
			positive = no
			visible = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_critical_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = bandit
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
			}
		}
	}
}

# Act as hired muscle
laamp_base_1011 = {
	group = laamp_contracts_hireling_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_martial_value
		add = laamp_contracts_weight_up_martial_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that want to be effective but subtle.
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that feel this type of manipulation is beneath them
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				## Plus just some where the narrative would feel weird.
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = sadistic }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		## Won't resort to this.
		laamp_task_contract_employer_would_resort_to_violence_trigger = yes
		laamp_task_contract_employer_would_resort_to_deceit_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_1011_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.1011
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = var:gold_success_standard
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_medium_gain
						XP_MIN = knight_errant_xp_medium_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_major_gain
						XP_MIN = knight_errant_xp_major_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Ambush travellers
laamp_base_1041 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_martial_value
		add = laamp_contracts_weight_up_martial_slight_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that don't mind telegraphing weakness.
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = honest }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that wouldn't just admit something was wrong.
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
		# Must be at least a count.
		scope:employer.highest_held_title_tier >= tier_county
		# Plus make sure we'd have a valid destination to even grab.
		scope:employer.capital_county = {
			# Counts travel two duchies over.
			trigger_if = {
				limit = { scope:employer.highest_held_title_tier = tier_county }
				duchy = {
					any_title_to_title_neighboring_duchy = {
						any_title_to_title_neighboring_duchy = {
							this != scope:employer.capital_county.duchy
						}
					}
				}
			}
			# Dukes travel a kingdom over.
			trigger_else_if = {
				limit = { scope:employer.highest_held_title_tier = tier_duchy }
				kingdom = {
					any_title_to_title_neighboring_kingdom = { exists = this }
				}
			}
			# Kings and emperors travel an empire over.
			trigger_else = {
				empire = {
					any_title_to_title_neighboring_empire = { exists = this }
				}
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.1044 }
		# Plus, set up some variables for us.
		## Encounters list.
		increment_variable_effect = {
			VAR = encounters_tally
			VAL = 0
		}
		increment_variable_effect = {
			VAR = encounters_max
			VAL = 0
		}
		## Our actual haul.
		increment_variable_effect = {
			VAR = haul_actual
			VAL = 0
		}
		## Path length + length:event ratio — we'll use these to determine how quickly we should get the events.
		increment_variable_effect = {
			VAR = path_length
			VAL = 0
		}
		increment_variable_effect = {
			VAR = event_ratio
			VAL = 0
		}
		increment_variable_effect = {
			VAR = event_ratio_tracker
			VAL = 0
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Criminal Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_criminal_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				if = {
					limit = {
						NOT = { exists = scope:suppress_gold_warning }
					}
					custom_tooltip = laamp_base_1041.tt.gold_rewards_depend_on_travellers
				}
				else = { custom_tooltip = laamp_base_1041.tt.haul_actual }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = bandit
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = bandit
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}

# Go rustling
laamp_base_5031 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = laamp_contract_would_signpost_own_prosperity_value
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		scope:employer.sub_realm_size >= 2 
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
		# Specific flavour triggers.
		root.task_contract_employer.sub_realm_size >= 2 
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.5034 }
		# Plus, set up some variables for us.
		## Progress tallies.
		increment_variable_effect = {
			VAR = encounter_tally
			VAL = 0
		}
		increment_variable_effect = {
			VAR = encounter_max
			VAL = 0
		}
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 0
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_critical_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Criminal Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_criminal_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Critical Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MAX = gallowsbait_xp_major_gain
						XP_MIN = gallowsbait_xp_major_gain
					}
				}
			}
		}
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Criminal Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_criminal_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MIN = gallowsbait_xp_medium_gain
						XP_MAX = gallowsbait_xp_medium_gain
					}
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MIN = gallowsbait_xp_minor_gain
						XP_MAX = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}

# Mug people.
laamp_base_5051 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = { multiply = task_contract_weight_by_tier_value }
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		scope:employer.highest_held_title_tier >= tier_county
		NOT = { scope:employer = { government_has_flag = government_is_herder } }
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
		NOT = { scope:employer = { government_has_flag = government_is_herder } }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
		NOT = { scope:employer = { government_has_flag = government_is_herder } }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
		NOT = { scope:employer = { government_has_flag = government_is_herder } }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_5051_contract_scheme
				contract = root
				target_character = scope:task_contract.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.5051
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
			}
		}
	}
}












##################################################
# STEWARDSHIP CONTRACTS

# Collect taxes for a third party
laamp_base_2001 = {
	group = laamp_contracts_hireling_group
	icon = "gfx/interface/icons/scheme_types/stewardship.dds"

	travel = no
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_stewardship_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that want their money and think you can get it.
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that either can wait or won't trust you.
				if = {
					limit = { has_trait = paranoid }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		laamp_task_contract_employer_would_chase_money_trigger = yes
		# And we must have at least one mayor to act as the locus.
		scope:employer = {
			any_vassal = { laamp_base_2001_valid_mayor_trigger = yes }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
		# Make sure our baron hasn't died.
		var:person_a = { is_alive = yes }
		# And that, in MP, our secondaries haven't died either.
		OR = {
			NOT = { has_variable = person_b }
			var:person_b = { is_alive = yes }
		}
		OR = {
			NOT = { has_variable = person_c }
			var:person_b = { is_alive = yes }
		}
		OR = {
			NOT = { has_variable = person_d }
			var:person_b = { is_alive = yes }
		}
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Grab our best possible baron.
		scope:employer = {
			ordered_vassal = {
				limit = { laamp_base_2001_valid_mayor_trigger = yes }
				order_by = {
					value = ai_greed
					add = {
						value = ai_honor
						multiply = -0.5
					}
					# Weight down the capital if we can, as it feels weird to not go a city over.
					if = {
						limit = { primary_title.county.holder = scope:employer }
						add = -1000
					}
				}
				save_scope_as = person_a
			}
		}
		# Track this as a variable so that we can invalidate if they die.
		set_variable = {
			name = person_a
			value = scope:person_a
		}
		# Plus our score.
		increment_variable_effect = {
			VAR = clues_gathered
			VAL = 0
		}
		# & numbers of chars checked for loc.
		increment_variable_effect = {
			VAR = chars_checked
			VAL = 0
		}
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.2004 }
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			set_variable = {
				name = gold_success_qualified_reduced_tax
				value = task_contract_taker.task_contract_success_gold_gain_third_value
			}
			set_variable = {
				name = gold_success_qualified_insufficient_evidence
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			set_variable = {
				name = gold_success_qualified_beaten_down
				value = task_contract_taker.task_contract_success_gold_gain_third_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Critical Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_massive_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_qualified_reduced_tax = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified_reduced_tax
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_reduced_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		success_qualified_insufficient_evidence = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified_insufficient_evidence
					PRESTIGE = -200
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_qualified_beaten_down = {
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified_beaten_down
					PRESTIGE = -200
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_reduced_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		failure_critical = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = -300
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_critical_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_major_gain
						XP_MIN = gallowsbait_xp_major_gain
					}
				}
			}
		}
		failure_took_wrong_side = {
			visible = no
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:yes }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_success_prestige_gain_critical_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Perform a census
laamp_base_2011 = {
	group = laamp_contracts_stewardship_group
	icon = "gfx/interface/icons/scheme_types/stewardship.dds"

	travel = no
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_stewardship_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that care especially for rules and documentation.
				### A.k.a: the good kind of designer.
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't much care for paperwork, preferring vibes.
				### A.k.a: the bad kind of designer.
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		scope:employer = {
			domain_size >= 2
		}
		# Specific flavour triggers.
		scope:employer.laamp_base_2011_actual_surveyable_holdings_per_tier_value >= scope:employer.laamp_base_2011_desired_surveyable_holdings_per_tier_value
		## A census isn't necessarily about money but given the expense involved... yeah most of the time it is.
		laamp_task_contract_employer_would_chase_money_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.2014 }
		# Track our score.
		increment_variable_effect = {
			VAR = destinations_processed
			VAL = 0
		}
		# Plus our methods.
		increment_variable_effect = {
			VAR = destinations_processed_legit_success
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_quartermaster_success
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_lied_success
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_guessed_success
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_legit_failure
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_quartermaster_failure
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_lied_failure
			VAL = 0
		}
		increment_variable_effect = {
			VAR = destinations_processed_guessed_failure
			VAL = 0
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Critical Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		failure_critical = {
			positive = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = -300
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_critical_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_major_gain
						XP_MIN = gallowsbait_xp_major_gain
					}
				}
			}
		}
	}
}

# Help construct a building
laamp_base_2021 = {
	group = laamp_contracts_stewardship_group
	icon = "gfx/interface/icons/scheme_types/stewardship.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_stewardship_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that want fresh buildings but aren't great at organising such.
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that do well at construction.
				if = {
					limit = { has_trait = generous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		scope:employer = {
			NOR = {
				has_trait = architect
				stewardship >= high_skill_rating
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_2021_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.2021
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Critical Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_critical_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Settle a local dispute
laamp_base_2031 = {
	group = laamp_contracts_stewardship_group
	icon = "gfx/interface/icons/scheme_types/stewardship.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_stewardship_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that are likely to run into these kinds of political troubles but not super able to deal with them.
				if = {
					limit = { has_trait = honest }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that would avoid or swiftly resolve the issue.
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			# Don't weight down barons like we usually would, because we _only_ want barons here.
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		# This time around we're dealing with minor disputes, so we only want barons.
		scope:employer.highest_held_title_tier = tier_barony
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we roll our first event..
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.2035 }
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			set_variable = {
				name = success_camp_purpose
				value = task_contract_success_gold_gain_half_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			set_variable = {
				name = success_sacked_settlement
				value = task_contract_success_gold_gain_critical_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Critical Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_camp_purpose = {
			should_print_on_complete = yes
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:success_camp_purpose
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_sacked_settlement = {
			should_print_on_complete = yes
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:success_sacked_settlement
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_major_gain
						XP_MIN = gallowsbait_xp_major_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Collect fake taxes
laamp_base_2041 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/stewardship.dds"

	travel = no
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_stewardship_value
		add = laamp_contracts_weight_up_criminal_massive_value
		# Employer weights.
		scope:employer = {
			add = laamp_contract_would_signpost_own_prosperity_value
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		scope:employer.sub_realm_size >= laamp_base_2041_num_counties_to_rob_value
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.2044 }
		# Plus, set up some variables for us.
		## Progress tallies.
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 0
		}
		increment_variable_effect = {
			VAR = losses_tally
			VAL = 0
		}
		## Victory tiers.
		save_scope_value_as = {
			name = win_t1_threshold
			value = {
				value = scope:employer.laamp_base_2041_num_counties_to_rob_sans_capital_value
				divide = 3
				floor = yes
			}
		}
		increment_variable_effect = {
			VAR = win_t1_threshold
			VAL = scope:win_t1_threshold
		}
		save_scope_value_as = {
			name = win_t2_threshold
			value = {
				value = scope:employer.laamp_base_2041_num_counties_to_rob_sans_capital_value
				divide = 3
				multiply = 2
				floor = yes
			}
		}
		increment_variable_effect = {
			VAR = win_t2_threshold
			VAL = scope:win_t2_threshold
		}
		increment_variable_effect = {
			VAR = win_t3_threshold
			VAL = scope:employer.laamp_base_2041_num_counties_to_rob_sans_capital_value
		}
		## Roll difficulties.
		increment_variable_effect = {
			VAR = stewardship_diff
			VAL = 10
		}
		increment_variable_effect = {
			VAR = intrigue_diff
			VAL = 10
		}
		increment_variable_effect = {
			VAR = bard_diff
			VAL = 0
		}
		increment_variable_effect = {
			VAR = stress_charge
			VAL = 20
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
			set_variable = {
				name = gold_success_qualified
				value = task_contract_taker.task_contract_success_gold_gain_half_crime_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_critical_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
				}
			}
		}
		success_qualified = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_major_gain
						XP_MIN = gallowsbait_xp_major_gain
					}
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}
		failure_qualified = {
			positive = no
			should_print_on_complete = yes
			visible = no
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_backed_down_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}











##################################################
# INTRIGUE CONTRACTS

# Provide intelligence from your trips
laamp_base_3001 = {
	group = laamp_contracts_intrigue_group
	icon = "gfx/interface/icons/scheme_types/intrigue.dds"

	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_intrigue_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that value foreign intelligence.
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't care for espionage.
				if = {
					limit = { has_trait = honest }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		scope:employer = {
			highest_held_title_tier >= tier_county
			OR = {
				any_neighboring_and_across_water_realm_same_rank_owner = {
					count >= 3
					laamp_base_3001_valid_neighbours_trigger = { EMPLOYER = scope:employer }
				}
				AND = {
					highest_held_title_tier >= tier_empire
					any_neighboring_and_across_water_top_liege_realm_owner = {
						count >= 3
						highest_held_title_tier >= tier_kingdom
						laamp_base_3001_valid_neighbours_trigger = { EMPLOYER = scope:employer }
					}
				}
			}
		}
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.3004 }
		# Plus, set up a tracking variable for us.
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 0
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			set_variable = {
				name = gold_success_qualified
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_qualified = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Murder a character's rival
laamp_base_3011 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/intrigue.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_intrigue_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that want someone killed and don't much care how.
				if = {
					limit = { has_trait = wrathful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = sadistic }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that won't hire thugs to solve their problems just on principle.
				if = {
					limit = { has_trait = calm }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		# Specific flavour triggers.
		laamp_task_contract_employer_would_resort_to_violence_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Now, nab us a suitable target.
		task_contract_employer = { laamp_contract_grab_suitable_rival_for_disposal_effect = yes }
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_3011_contract_scheme
				contract = root
				target_character = root.var:target
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.3011
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 1
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
			}
		}
	}
}

# Abduct a character's rival
laamp_base_3021 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/intrigue.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_intrigue_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that like a personal touch in the ol' donjon.
				if = {
					limit = { has_trait = sadistic }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = wrathful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that prefer efficiency.
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		# Specific flavour triggers.
		laamp_task_contract_employer_would_resort_to_violence_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Now, nab us a suitable target.
		task_contract_employer = { laamp_contract_grab_suitable_rival_for_disposal_effect = yes }
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_3021_contract_scheme
				contract = root
				target_character = root.var:target
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.3021
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 1
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_medium_gain
						XP_MIN = gallowsbait_xp_medium_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
				
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = marauder
						XP_MAX = gallowsbait_xp_minor_gain
						XP_MIN = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}

# Attack the property of a character's rival
laamp_base_3031 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/intrigue.dds"

	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_intrigue_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that like a subtle, yet violent, touch.
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				### Ok emphasising "violent" over "subtle" here.
				if = {
					limit = { has_trait = wrathful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that prefer bluntness or honesty.
				if = {
					limit = { has_trait = honest }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = calm }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		laamp_task_contract_employer_would_resort_to_violence_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Now, nab us a suitable target.
		task_contract_employer = { laamp_contract_grab_suitable_rival_for_disposal_effect = yes }
		# Save a scope that stops us getting double gallowsbait XP later on.
		save_scope_value_as = {
			name = suppress_gallowsbait
			value = yes
		}
		# Then we start the chainlet.
		task_contract_taker ?= { trigger_event = laamp_base_contract_schemes.3034 }
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 1
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update gallowsbait score.
				task_contract_taker = {
					if = {
						limit = {
							NOT = { exists = scope:suppress_gallowsbait }
						}
						# Wrapped like this because, even with the scope definitely present, it was somehow slipping the net & applying anyway.
						show_as_tooltip = {
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = bandit
								XP_MIN = gallowsbait_xp_medium_gain
								XP_MAX = gallowsbait_xp_medium_gain
							}
						}
					}
					bandit_king_maa_spawn_effect = yes
				}
				
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					if = {
						limit = {
							NOT = { exists = scope:suppress_gallowsbait }
						}
						# Wrapped like this because, even with the scope definitely present, it was somehow slipping the net & applying anyway.
						show_as_tooltip = {
							laamp_rewards_apply_criminal_xp_effect = {
								TRACK = bandit
								XP_MIN = gallowsbait_xp_minor_gain
								XP_MAX = gallowsbait_xp_minor_gain
							}
						}
					}
				}
			}
		}
		failure_qualified = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_half_value
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Heist from a ruler's treasury
laamp_base_3041 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/intrigue.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_intrigue_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = laamp_contract_would_signpost_own_prosperity_value
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_3041_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.3041
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MIN = gallowsbait_xp_medium_gain
						XP_MAX = gallowsbait_xp_medium_gain
					}
					bandit_king_maa_spawn_effect = yes
				}
				custom_tooltip = laamp_base_3041.tt.chance_for_more
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = thief
						XP_MIN = gallowsbait_xp_minor_gain
						XP_MAX = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}











##################################################
# LEARNING CONTRACTS

# Transcribe texts for a learned ruler
laamp_base_4001 = {
	group = laamp_contracts_learning_group
	icon = "gfx/interface/icons/scheme_types/learning.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_learning_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that appreciate works of learning.
				if = {
					limit = { has_trait = scholar }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = theologian }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = eccentric }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't support these gorramned NERDS.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = athletic }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	on_create = {
		scope:contract = {
			save_scope_as = task_contract
			set_variable = {
				name = task_contract_employer
				value = scope:task_contract.task_contract_employer
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			set_variable = {
				name = gold_success_qualified
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_critical_value
			}
		}
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For easy access
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Trigger the first education event
		task_contract_taker ?= { trigger_event = laamp_base_learning_contract_events.4001 }
		# Plus, set up some variables for us.
		## Progress tallies.
		increment_variable_effect = {
			VAR = score_tally
			VAL = 0
		}
		increment_variable_effect = {
			VAR = text_passages_left
			VAL = 3
		}
		### Victory tiers.
		increment_variable_effect = {
			VAR = win_t1_threshold
			VAL = 3 #You smooch by on the standard answer
		}
		increment_variable_effect = {
			VAR = win_t2_threshold
			VAL = 7 #You use your language/traits twice and also have a successful embellishment
		}
		increment_variable_effect = {
			VAR = win_t3_threshold
			VAL = 9 #All three embellishments are successful :yeslikethis:
		}
	}

	# Rewards
	task_contract_reward = {
		success_qualified = {
			should_print_on_complete = yes
			effect = {
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_reduced_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = task_contract_success_piety_gain_half_value
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = task_contract_success_piety_gain_full_value
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

#Help settle theological arguments
laamp_base_4011 = {
	group = laamp_contracts_learning_group
	icon = "gfx/interface/icons/scheme_types/learning.dds"

	travel = no
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_learning_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that would happily delegate a debate.
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that would leap into a debate wholesale.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		scope:employer = {
			NOR = {
				government_has_flag = government_is_tribal
				faith = { has_doctrine_parameter = unreformed }
				has_trait = cynical
			}
			AND = {
				highest_held_title_tier >= tier_duchy
				any_sub_realm_barony = {
					title_province = { has_holding = yes }
					this != scope:employer.capital_barony
					count >= 3
				}
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For easy access
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		#Set this up here to calculate win thresholds
		scope:employer = {
			add_character_flag = is_in_task_contract_event_chain
			ordered_sub_realm_barony = {
				limit = { 
					title_province = { has_holding = yes }
					this != scope:employer.capital_barony
				}
				order_by = {
					value = county_opinion
					multiply = -1
				}
				max = 5
				check_range_bounds = no
				add_to_list = destination_baronies_list
			}
			scope:employer.capital_province = { save_scope_as = employer_location_destination }
			ordered_in_list = {
				list = destination_baronies_list
				order_by = "squared_distance(prev.capital_province)"
				max = 5
				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
				}
			}
		}
		# Plus, set up some variables for us.
		## Progress tallies.
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 0
		}
		increment_variable_effect = {
			VAR = encounter_tally
			VAL = 0
		}
		### Victory tiers.
		if = {
			limit = { exists = scope:destination_5 }
			increment_variable_effect = {
				VAR = win_t1_threshold
				VAL = 2
			}
			increment_variable_effect = {
				VAR = win_t2_threshold
				VAL = 4
			}
			increment_variable_effect = {
				VAR = win_t3_threshold
				VAL = 5
			}
		}
		else_if = {
			limit = { exists = scope:destination_4 }
			increment_variable_effect = {
				VAR = win_t1_threshold
				VAL = 1
			}
			increment_variable_effect = {
				VAR = win_t2_threshold
				VAL = 2
			}
			increment_variable_effect = {
				VAR = win_t3_threshold
				VAL = 4
			}
		}
		else = {
			increment_variable_effect = {
				VAR = win_t1_threshold
				VAL = 1
			}
			increment_variable_effect = {
				VAR = win_t2_threshold
				VAL = 2
			}
			increment_variable_effect = {
				VAR = win_t3_threshold
				VAL = 3
			}
		}
		increment_variable_effect = {
			VAR = opportunities_left_tally
			VAL = var:win_t3_threshold
		}
		# Then we start the travel.
		task_contract_taker ?= { trigger_event = laamp_base_learning_contract_events.4011 }
	}
	on_invalidated = {
		task_contract_employer = { remove_character_flag = is_in_task_contract_event_chain }
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_qualified
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_critical_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_qualified = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = task_contract_success_piety_gain_half_value
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_reduced_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_employer = { remove_character_flag = is_in_task_contract_event_chain }
			}
		}
		success_standard = {
			should_print_on_complete = yes
			effect = {
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = task_contract_success_piety_gain_full_value
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_employer = { remove_character_flag = is_in_task_contract_event_chain }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_critical_value
					PIETY = task_contract_success_piety_gain_critical_value
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_employer = { remove_character_flag = is_in_task_contract_event_chain }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = 0
					PIETY = task_contract_failure_piety_loss_full_value
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_employer = { remove_character_flag = is_in_task_contract_event_chain }
			}
		}
	}
}

# Create a work of learning for a ruler
laamp_base_4021 = {
	group = laamp_contracts_learning_group
	icon = "gfx/interface/icons/scheme_types/learning.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_learning_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that appreciate works of learning.
				if = {
					limit = { has_trait = scholar }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = theologian }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = eccentric }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't support these gorramned NERDS.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = athletic }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		#You really shouldn't have terrible Learning
		root.learning >= average_skill_level
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For easy access
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# How many chapters do you want to write?
		task_contract_taker ?= { trigger_event = laamp_base_learning_contract_events.4021 }
		#We set up the variables in the intro event
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_qualified
				value = task_contract_taker.task_contract_success_gold_gain_half_value
			}
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_qualified = {
			should_print_on_complete = yes
			effect = {
				# Camp building extra Stewardship Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_stewardship_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				# Standard Reward.
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_qualified
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_reduced_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = task_contract_success_piety_gain_half_value
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = task_contract_success_piety_gain_half_value
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = task_contract_failure_piety_loss_full_value
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Solicit Charity
laamp_base_4031 = {
	group = laamp_contracts_learning_group
	icon = "gfx/interface/icons/scheme_types/learning.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_learning_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that take pity on passers by.
				if = {
					limit = { has_trait = generous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = compassionate }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = improvident }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = profligate }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't give a damn about wanderers (or who it would look a bit weird for).
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = sadistic }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_4031_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.4031
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = 0
					PIETY = task_contract_success_piety_gain_half_value
					PROVISIONS = task_contract_success_provisions_gain_massive_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = task_contract_failure_piety_loss_full_value
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Sell bogus relics
laamp_base_4041 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/learning.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_learning_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that make you gullible, or at least more vulnerable to scam artistry.
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = eccentric }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that make you naturally suspicious.
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		scope:employer = {
			NOR = {
				government_has_flag = government_is_tribal
				faith = { has_doctrine_parameter = unreformed }
			}
		}
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_4041_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.4041
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_crime_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Learning/Criminal Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= {
							OR = {
								has_domicile_parameter = camp_improved_learning_contract_rewards
								has_domicile_parameter = camp_improved_criminal_contract_rewards
							}
						}
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MIN = gallowsbait_xp_medium_gain
						XP_MAX = gallowsbait_xp_medium_gain
					}
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = task_contract_failure_piety_loss_full_value
					PROVISIONS = 0
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = trickster
						XP_MIN = gallowsbait_xp_minor_gain
						XP_MAX = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}

#Act as a tutor for ruler's child
laamp_base_4100 = {
	group = laamp_contracts_learning_group
	icon = "gfx/interface/icons/scheme_types/learning.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_learning_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that appreciate works of learning.
				if = {
					limit = { has_trait = scholar }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = theologian }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = eccentric }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = patient }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't support these gorramned NERDS.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = impatient }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = athletic }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		# Specific flavour triggers.
		scope:employer = {
			any_courtier = {
				age >= 6
				age < 15 #Give us a year to complete the contract
				is_available = yes
				location = scope:employer.location
			}
		}
	}

	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}

	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
		root.var:task_contract_target = { age < 15 }
		#Since the kid is saved as the target; we automatically invalidate if kid becomes unavailable, right?
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	on_create = {
		scope:contract = {
			save_scope_as = task_contract
			task_contract_employer = {
				random_courtier = {
					limit = {
						age >= 6
						age < 15 #Give us a year to complete the contract
						is_available = yes
						location = prev.location #The employer's location
					}
					weight = {
						base = 1
						#Prioritize relevant children
						modifier = {
							add = 10
							is_primary_heir_of = scope:task_contract.task_contract_employer
						}
						modifier = {
							add = 5
							trigger_if = {
								limit = {
									scope:task_contract.task_contract_employer = { has_realm_law = female_only_law }
								}
								is_female = yes
							}
							trigger_else = { always = no }
						}
						modifier = {
							add = 5
							trigger_if = {
								limit = {
									scope:task_contract.task_contract_employer = { has_realm_law = male_only_law }
								}
								is_male = yes
							}
							trigger_else = { always = no }
						}
					}
					save_scope_as = task_contract_target
				}
			}
			set_variable = {
				name = task_contract_employer
				value = scope:task_contract.task_contract_employer
			}
			set_task_contract_target = scope:task_contract_target
			set_variable = {
				name = task_contract_target
				value = scope:task_contract.task_contract_target
			}
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_critical_value
			}
		}
	}

	# On_actions
	on_accepted = {
		# For easy access
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		task_contract_target = { save_scope_as = child_to_educate }
		# Trigger the first education event
		task_contract_taker ?= { trigger_event = laamp_base_learning_contract_events.4100 }
		# Plus, set up some variables for us.
		## Progress tallies.
		increment_variable_effect = {
			VAR = wins_tally
			VAL = 0
		}
		increment_variable_effect = {
			VAR = educational_moments_left
			VAL = 3
		}
		### Victory tiers.
		increment_variable_effect = {
			VAR = win_t1_threshold
			VAL = 2
		}
		increment_variable_effect = {
			VAR = win_t2_threshold
			VAL = 3
		}
		## Roll difficulties.
		increment_variable_effect = {
			VAR = learning_diff
			VAL = 10
		}
		increment_variable_effect = {
			VAR = topic_diff
			VAL = 10
		}
		increment_variable_effect = {
			VAR = support_person_diff
			VAL = 5
		}
		increment_variable_effect = {
			VAR = stress_charge
			VAL = 20
		}
	}

	on_invalidated = {
		task_contract_taker = {
			remove_character_flag = is_in_task_contract_event_chain 
		}
		if = {
			limit = {
				root.task_contract_taker = {
					any_character_active_contract = {
						this = root
					}
				}
			}
			task_contract_employer = {
				save_scope_as = task_contract_employer
			}
			save_scope_value_as = {
				name = task_contract_tier
				value = root.task_contract_tier
			}
			var:task_contract_target = {
				save_scope_as = task_contract_target
			}

			task_contract_taker = {
				set_variable = {
					name = invalidated_task_contract_type
					value = flag:laamp_base_4100
				}
			}
			if = {
				limit = {
					task_contract_employer = {
						is_alive = no
					}
				}
				task_contract_employer.primary_title.holder ?= {
					save_scope_as = employer_heir
				}
				task_contract_taker = {
					save_scope_value_as = {
						name = task_contract_invalidation_reason
						value = flag:employer_dead
					}
					trigger_event = ep3_contract_event.0012
				
				}
			}
			else_if = {
				limit = {
					scope:task_contract_target = {
						is_alive = no
					}
				}
				task_contract_taker = {
					save_scope_value_as = {
						name = task_contract_invalidation_reason
						value = flag:target_dead
					}
					trigger_event = ep3_contract_event.0012
				}
			}
		}
	}
	# Rewards
	task_contract_reward = {
		#Need at least 2 successful teaching moments
		success_standard = {
			should_print_on_complete = yes
			effect = {
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				# Camp building extra Learning Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_learning_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_critical_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}











##################################################
# JUSTICAR CONTRACTS

# Protect the innocent
laamp_base_6001 = {
	group = laamp_contracts_justicar_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that value prosperity in their subjects.
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = generous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = humble }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = avaricious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that won't do favours for some grubby merchant.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_6001_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.6001
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
			# Make sure critical values are a bit higher.
			save_scope_value_as = { name = gold_safety_margin value = flag:yes }
			set_variable = {
				name = gold_success_critical
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_taker = {
					# Update gallowsbait score.
					lower_gallowsbait_xp_effect = { VALUE = -5 }
					# Update Knight-Errant score.
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_critical
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_taker = {
					# Update gallowsbait score.
					lower_gallowsbait_xp_effect = { VALUE = -10 }
					# Update Knight-Errant score.
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_medium_gain
						XP_MIN = knight_errant_xp_medium_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Rescue a Fair Non-Combatant Gender
laamp_base_6011 = {
	group = laamp_contracts_justicar_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				if = {
					limit = { has_trait = gallant }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				
				# Weight down
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
			scope:employer.capital_province = { is_wooded_trigger = yes }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_6011_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.6011
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = task_contract_success_provisions_gain_minor_value
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_taker = {
					# Update gallowsbait score.
					lower_gallowsbait_xp_effect = { VALUE = -5 }
					# Update Knight-Errant score.
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Participate in a Chivalry Play
laamp_base_6021 = {
	group = laamp_contracts_justicar_group
	icon = "gfx/interface/icons/scheme_types/diplomacy.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_diplomacy_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				if = {
					limit = { has_trait = gallant }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lifestyle_reveler }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				
				# Weight down
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_6021_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.6021
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_taker = {
					# Update Knight-Errant score.
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Do a Pass d'Armes
laamp_base_6031 = {
	group = laamp_contracts_justicar_group
	icon = "gfx/interface/icons/scheme_types/martial.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				if = {
					limit = { has_trait = gallant }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		employer_has_treasury_to_offer_job_trigger = yes
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		task_contract_employer = { save_scope_as = employer }
		# Then we start the scheme.
		task_contract_taker ?= {
			start_scheme = {
				type = laamp_base_6031_contract_scheme
				contract = root
				target_character = root.task_contract_employer
			}
			# Make a note of what the scheme even is; we'll need this for the event too.
			scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.6031
		}
	}
	on_create = {
		scope:contract = {
			# Make our gold rewards static.
			grab_gold_fuzz_number_effect = yes
			save_scope_as = task_contract
			set_variable = {
				name = gold_success_standard
				value = task_contract_taker.task_contract_success_gold_gain_full_value
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = scope:task_contract.var:gold_success_standard
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				task_contract_taker = {
					# Update gallowsbait score.
					lower_gallowsbait_xp_effect = { VALUE = -10 }
					# Update Knight-Errant score.
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}











##################################################
# DEPRECATED CONTRACTS

# Help train local MaA
laamp_base_1021 = {
	group = laamp_contracts_martial_group
	icon = "gfx/interface/icons/scheme_types/martial.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_martial_value
		add = laamp_contracts_weight_up_martial_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that believe in readiness for war.
				if = {
					limit = { has_trait = brave }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = wrathful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that don't think they gain anything from this.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		always = no
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			#start_scheme = {
			#	type = laamp_base_1021_contract_scheme
			#	contract = root
			#	target_character = root.task_contract_employer
			#}
			# Make a note of what the scheme even is; we'll need this for the event too.
			#scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.1021
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_massive_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_medium_gain
						XP_MIN = knight_errant_xp_medium_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Garrison service
laamp_base_1031 = {
	group = laamp_contracts_hireling_group
	icon = "gfx/interface/icons/scheme_types/martial.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_martial_value
		add = laamp_contracts_weight_up_martial_slight_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that care about defence.
				### We don't check paranoid because they're already filtered out due to this being relative strangers.
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that think their defences are definitely fiiiiiine.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		always = no
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		laamp_task_contract_employer_not_antisocial_trigger = yes
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			#start_scheme = {
			#	type = laamp_base_1031_contract_scheme
			#	contract = root
			#	target_character = root.task_contract_employer
			#}
			# Make a note of what the scheme even is; we'll need this for the event too.
			#scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.1031
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_massive_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Hunt in the wilds
laamp_base_5001 = {
	group = laamp_contracts_hunting_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that hate being outdoors.
				if = {
					limit = { has_trait = shy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = lazy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = craven }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that love being outside.
				if = {
					limit = { has_trait = gregarious }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = diligent }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		always = no
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		# Specific flavour triggers.
		scope:employer = {
			NOR = {
				has_trait = lifestyle_hunter
				has_trait = athletic
				has_trait = brave
			}
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			#start_scheme = {
			#	type = laamp_base_5001_contract_scheme
			#	contract = root
			#	target_character = root.task_contract_employer
			#}
			# Make a note of what the scheme even is; we'll need this for the event too.
			#scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.5001
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Counts towards Knight of the Swan
				task_contract_taker = {
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_massive_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Counts towards Knight of the Swan
				task_contract_taker = {
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Guard merchant properties
laamp_base_5011 = {
	group = laamp_contracts_hireling_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that value prosperity in their subjects.
				if = {
					limit = { has_trait = greedy }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = generous }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = humble }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = avaricious }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that won't do favours for some grubby merchant.
				if = {
					limit = { has_trait = arrogant }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = callous }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		always = no
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			#start_scheme = {
			#	type = laamp_base_5011_contract_scheme
			#	contract = root
			#	target_character = root.task_contract_employer
			#}
			# Make a note of what the scheme even is; we'll need this for the event too.
			#scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.5011
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_medium_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_minor_gain
						XP_MIN = knight_errant_xp_minor_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		success_critical = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Critical Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_half_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_excelled_reward_value
					OPINION_TYPE = critically_succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_medium_gain
						XP_MIN = knight_errant_xp_medium_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Guard a local ruler at a minor event
laamp_base_5021 = {
	group = laamp_contracts_hireling_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		# Employer weights.
		scope:employer = {
			add = {
				# Weight up.
				## Traits that suspect treason: either because they're paranoid or as a self-report.
				if = {
					limit = { has_trait = paranoid }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = deceitful }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = arbitrary }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = fickle }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = disloyal }
					add = task_contract_weight_bonus_employer_has_associated_traits_value
				}
				# Weight down.
				## Traits that think loyalty is unshakeable.
				if = {
					limit = { has_trait = trusting }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = honest }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = just }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = stubborn }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				if = {
					limit = { has_trait = loyal }
					add = task_contract_weight_malus_employer_has_associated_traits_value
				}
				# Restrictions.
				min = task_contract_weight_employer_associated_traits_min_value
				max = task_contract_weight_employer_associated_traits_max_value
			}
			multiply = task_contract_weight_by_tier_value
			# This weight is an override, so make sure it's placed at the bottom.
			add = task_contract_weight_employer_contact_list_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		always = no
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
		# Specific flavour triggers.
		OR = {
			laamp_task_contract_employer_not_antisocial_trigger = yes
			# Grant an exception to the paranoid antisocialness here: narratively, it's presented like their paranoia of their guards overwhelms their paranoia of you.
			has_trait = paranoid
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			#start_scheme = {
			#	type = laamp_base_5021_contract_scheme
			#	contract = root
			#	target_character = root.task_contract_employer
			#}
			# Make a note of what the scheme even is; we'll need this for the event too.
			#scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.5021
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_full_value
					PRESTIGE = task_contract_success_prestige_gain_full_value
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_reward_value
					OPINION_TYPE = succeeded_task_contract_opinion
					CONTACT = yes
					CONTACT_HOOK = yes
					EXTRA_REWARD = scope:extra_reward
				}
				task_contract_taker = { task_successful_noncrim_contract_count_effect = yes }
				# Update Knight-Errant score.
				task_contract_taker = {
					laamp_rewards_apply_knight_errant_xp_effect = {
						XP_MAX = knight_errant_xp_medium_gain
						XP_MIN = knight_errant_xp_medium_gain
					}
					task_contract_justicar_contract_tracker_effect = yes
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_full_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_standard_failure_value
					OPINION_TYPE = failed_task_contract_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
			}
		}
	}
}

# Go poaching
laamp_base_5041 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/war.dds"

	travel = yes
	is_criminal = yes
	use_diplomatic_range = no

	weight = {
		# Standard weights.
		value = task_contract_weight_default_value
		add = laamp_contracts_weight_up_prowess_value
		add = laamp_contracts_weight_up_criminal_value
		# Employer weights.
		scope:employer = {
			add = laamp_contract_would_signpost_own_prosperity_value
			multiply = task_contract_weight_by_tier_value
		}
	}

	# Validity Triggers
	valid_to_create = {
		always = no
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		valid_laamp_sensible_start_trigger = yes
		rule_out_dramatic_laamp_employers_trigger = yes
		NOT = {
			scope:employer = { government_has_flag = government_is_tribal }
		}
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:employer
			LAAMP = root
		}
		NOT = {
			house = {
				has_house_modifier = legacy_adventurer_house_modifier
			}
		}
		scope:employer = { is_landed = yes }
	}
	valid_to_continue = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		root.task_contract_taker = {
			NOT = {
				house = {
					has_house_modifier = legacy_adventurer_house_modifier
				}
			}
		}
		task_contract_employer = { is_landed = yes }
	}
	valid_to_keep = {
		# Standard triggers.
		valid_laamp_basic_trigger = {
			EMPLOYER = root.task_contract_employer
			LAAMP = root.task_contract_taker
		}
		task_contract_employer = { is_landed = yes }
	}

	# On_actions
	on_accepted = {
		task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_accept_contract" }
		# For the intro event.
		save_scope_as = task_contract
		# Then we start the scheme.
		task_contract_taker ?= {
			#start_scheme = {
			#	type = laamp_base_5041_contract_scheme
			#	contract = root
			#	target_character = root.task_contract_employer
			#}
			# Make a note of what the scheme even is; we'll need this for the event too.
			#scope:task_contract.scheme = { save_scope_as = scheme }
			trigger_event = laamp_base_contract_schemes.5041
		}
	}
	on_create = {
		scope:contract = {
			set_variable = {
				name = animation
				value = 0
			}
		}
	}

	# Rewards
	task_contract_reward = {
		success_standard = {
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_success_on_contract" }
				# Camp building extra Criminal Rewards: +50%.
				if = {
					limit = {
						task_contract_taker.domicile ?= { has_domicile_parameter = camp_improved_criminal_contract_rewards }
					}
					save_scope_value_as = { name = extra_reward value = flag:yes }
				}
				else = {
					save_scope_value_as = { name = extra_reward value = flag:no }
				}
				# Standard Rewards.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = task_contract_success_gold_gain_crime_value
					PRESTIGE = 0
					PIETY = 0
					PROVISIONS = task_contract_success_provisions_gain_major_value
					OPINION = task_contract_opinion_crime_success_value
					OPINION_TYPE = succeeded_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MIN = gallowsbait_xp_medium_gain
						XP_MAX = gallowsbait_xp_medium_gain
					}
				}
			}
		}
		failure_standard = {
			positive = no
			should_print_on_complete = yes
			effect = {
				task_contract_taker = { play_sound_effect = "event:/DLC/EP3/SFX/UI/Contracts/ep3_ui_contracts_failure_on_contract" }
				save_scope_value_as = { name = extra_reward value = flag:no }
				# Standard Penalties.
				laamp_rewards_disburse_ordinary_currency_effect = {
					GOLD = 0
					PRESTIGE = task_contract_failure_prestige_loss_crime_value
					PIETY = 0
					PROVISIONS = task_contract_failure_provisions_gain_minor_value
					OPINION = task_contract_opinion_crime_failure_value
					OPINION_TYPE = attempted_criminal_contract_against_me_opinion
					CONTACT = no
					CONTACT_HOOK = no
					EXTRA_REWARD = scope:extra_reward
				}
				# Update gallowsbait score.
				task_contract_taker = {
					laamp_rewards_apply_criminal_xp_effect = {
						TRACK = poacher
						XP_MIN = gallowsbait_xp_minor_gain
						XP_MAX = gallowsbait_xp_minor_gain
					}
				}
			}
		}
	}
}
