﻿spread_plague_interaction = {
	icon = spread_plague
	category = interaction_category_hostile
	scheme = spread_plague
	common_interaction = no
	interface_priority = 60
	ignores_pending_interaction_block = yes
	send_name = START_SCHEME

	desc = spread_plague_interaction_desc

	is_shown = {
		scope:recipient != scope:actor
		scope:recipient = {
			highest_held_title_tier >= tier_county
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = spread_plague
				target_character = scope:recipient
			}
		}
	}

	# Scheme Starter Packages
	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	## Balanced agents.
	send_option = {
		flag = agent_focus_balance
		current_description = spread_plague_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = spread_plague_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = spread_plague_interaction.tt.agent_focus_speed
	}
    ## Focused on Secrecy.
	send_option = {
		flag = agent_focus_secrecy
		current_description = spread_plague_interaction.tt.agent_focus_secrecy
	}
	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = spread_plague_interaction_notification
				left_icon = scope:actor					

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = spread_plague
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_assassin
						AGENT_2 = agent_assassin
						AGENT_3 = agent_alchemist
						# Speed.
						AGENT_4 = agent_infiltrator
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = spread_plague
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_assassin
						# Speed.
						AGENT_2 = agent_infiltrator
						AGENT_3 = agent_supplier
						AGENT_4 = agent_planner
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
				# Secrecy.
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = spread_plague
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_assassin
						# Speed.
						AGENT_2 = agent_infiltrator
						# Secrecy.
						AGENT_3 = agent_lookout
						AGENT_4 = agent_lookout
						AGENT_5 = agent_courtesan
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = spread_plague
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_assassin
						AGENT_2 = agent_alchemist
						# Speed.
						AGENT_3 = agent_infiltrator
						AGENT_4 = agent_supplier
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
			}
		}
	}
	
	auto_accept = yes

	ai_target_quick_trigger = {
		adult = yes
	}
	ai_targets = { 
		ai_recipients = neighboring_rulers
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 0
		duchy = 72
		kingdom = 24
		empire = 36
		hegemony = 36
	}

	ai_potential = {
		is_ruler = yes
		ai_vengefulness >= high_positive_ai_value
		exists = court_position:master_assassin_court_position
		exists = var:master_assassin_is_spreading_plague
		var:master_assassin_is_spreading_plague = yes
		has_trait = sadistic
		NOT = { has_trait = compassionate }
	}

	ai_will_do = {
		# They shouldn't always do this.
		base = -50

		# Opinion
		opinion_modifier = {
			opinion_target = scope:recipient
			multiplier = -1
		}
		# At war with target
		modifier = {
			add = 100
			scope:actor = { is_at_war_with = scope:recipient } 
		}

		ai_value_modifier = { ai_compassion = -1 }
		ai_value_modifier = { ai_vengefulness = 1 }
		
		# Traits
		# Positive modifiers
		modifier = {
			add = 25
			scope:actor = { has_trait = vengeful }
		}
		modifier = {
			add = 25
			scope:actor = { has_trait = schemer }
			desc = ROUSE_RABBLE_SCHEMER
		}
		modifier = {
			add = 50
			scope:actor = { has_trait = torturer }
		}
		modifier = {
			add = 50
			scope:actor = { has_trait = lifestyle_physician }
		}
		modifier = {
			add = 25
			scope:actor = { has_trait = wrathful }
		}
		modifier = {
			add = 50
			scope:actor = { has_trait = lifestyle_herbalist }
		}

		# Negative modifiers
		modifier = {
			add = -25
			scope:actor = { has_trait = craven }
		}
		modifier = {
			add = -25
			scope:actor = { has_trait = lazy }
		}
		modifier = {
			add = -50
			scope:actor = { has_trait = generous }
		}
		modifier = {
			add = -25
			scope:actor = { has_trait = forgiving }
		}
		modifier = {
			add = -100
			scope:actor = { has_trait = infirm }
		}
	}
}