﻿# Challenge Status
start_challenge_status_interaction = {
	icon = icon_scheme_challenge_status
	interface_priority = 80
	category = interaction_category_admin

	send_name = START_SCHEME

	scheme = challenge_status
	ignores_pending_interaction_block = yes

	#ai_frequency = 120
	ai_frequency = 0
	ai_will_do = { base = 0 }
	
	is_shown = {
		scope:actor = {
			government_allows = administrative
		}
		scope:recipient != scope:actor
		scope:recipient = {
			government_allows = administrative
			top_liege = scope:actor.top_liege
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			can_start_scheme = {
				type = challenge_status
				target_character = scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:actor = {
					can_start_scheme = {
						type = challenge_status
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_challenge_status_approved
		}
	}

	# Scheme Starter Packages
	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	## Balanced agents.
	send_option = {
		flag = agent_focus_balance
		current_description = start_challenge_status_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_challenge_status_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_challenge_status_interaction.tt.agent_focus_speed
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_challenge_status_notification

				left_icon = scope:actor
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = challenge_status
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						AGENT_3 = agent_sycophant
						# Speed.
						AGENT_4 = agent_political_socialite
						AGENT_5 = agent_bureaucrat
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = challenge_status
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						# Speed.
						AGENT_3 = agent_political_socialite
						AGENT_4 = agent_bureaucrat
						AGENT_5 = agent_bureaucrat
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = challenge_status
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						# Speed.
						AGENT_3 = agent_political_socialite
						AGENT_4 = agent_bureaucrat
						# Secrecy.
						AGENT_5 = agent_amanuensis
					}
				}
			}
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
			custom_tooltip = challenge_status_success_actor_tt
		}
		scope:recipient = {
			save_scope_as = target
			custom_tooltip = challenge_status_success_recipient_tt
		}
	}

	auto_accept = yes
}