﻿mercenary_contract_0001 = {
	group = laamp_contracts_criminal_group
	icon = "gfx/interface/icons/scheme_types/intrigue.dds"

	travel = no
	is_criminal = yes
	use_diplomatic_range = no

	# Validity Triggers
	valid_to_create = {
		# Standard triggers.
		$EMPLOYER$ = {
		# Players shouldn't get tangled up in contracts, ever.
		is_ai = yes
		# Plus some standard stuff.
		is_alive = yes
		is_adult = yes
	    }
		# Specific flavour triggers.
	}
	valid_to_accept = {
		# Standard triggers.
		valid_laamp_basic_accept_only_trigger = yes
		$EMPLOYER$ = {
		# Players shouldn't get tangled up in contracts, ever.
		is_ai = yes
		# Plus some standard stuff.
		is_alive = yes
		is_adult = yes
		is_ruler = yes
	    }
	}
	valid_to_continue = {
		# Standard triggers.
		$EMPLOYER$ = {
		# Players shouldn't get tangled up in contracts, ever.
		is_ai = yes
		# Plus some standard stuff.
		is_alive = yes
		is_adult = yes
		is_ruler = yes
	    }
	}
	valid_to_keep = {
		# Standard triggers.
		$EMPLOYER$ = {
		# Players shouldn't get tangled up in contracts, ever.
		is_ai = yes
		# Plus some standard stuff.
		is_alive = yes
		is_adult = yes
		is_ruler = 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.
		random_ruler = { limit = { is_landless_administrative = yes } save_scope_as = rival_target }
		# Then we start the scheme.
		task_contract_taker = {
			start_scheme = {
				type = mercenary_contract_0001
				contract = root
				target_character = scope:rival_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 = rtr.0101
		}
	}
	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
				}
				# 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
				}
			}
		}
	}
}