﻿sas_surveil_target_interaction = {
	icon = sas_spy_icon
	category = interaction_category_hostile
	interface_priority = 40
	desc = sas_surveil_target_interaction_desc

 	cooldown = { years = 2 }

	is_shown = {
		scope:recipient != scope:actor
		scope:actor = {
			is_ai = no
			is_alive = yes
			trigger_if = {
				limit = { exists = var:surveil_target }
				NOT = { var:surveil_target = scope:recipient }
			}
			exists = house
			house = {
				OR = {
					has_house_modifier = sas_special_operations_training_house_modifier_free
					has_house_modifier = sas_special_operations_training_house_modifier_paid
				}
			}
			has_game_rule = sas_surveil_target_enabled
		}
	}

	is_valid_showing_failures_only = {
		custom_description = {
			text = survelling_other_target
			scope:actor = {
				NOT = { exists = var:surveil_target }
			}
		}
		custom_description = {
			text = target_is_in_spy_network
			NOT = {
				scope:actor = {
					is_target_in_variable_list = {
						name = spy_network_members
						target = scope:recipient
					}
				}
			}
		}
		custom_description = {
			text = spy_network_extends_to_targets_court
			scope:actor = {
				any_in_list = {
					variable = spy_network_members
					is_alive = yes
					OR = {
						court_owner = scope:recipient
						court_owner = scope:recipient.court_owner
					}
				}
			}
		}
	}

	auto_accept = yes
	on_accept = {
		scope:actor = {
			set_variable = {
				name = surveil_target
				value = scope:recipient
			}
		}
		scope:recipient = {
			custom_tooltip = surveil_target_interaction_start_surveillance.tt
		}
		scope:recipient = {
			add_to_variable_list = {
				name = players_surveilling_me
				target = scope:actor
			}
		}
	}

	is_available = {
		is_ai = no
	}
}

sas_stop_surveil_target_interaction = {
	icon = sas_spy_icon
	category = interaction_category_hostile
 	common_interaction = yes
	interface_priority = 150
	desc = sas_stop_surveil_target_interaction_desc

	is_shown = {
		scope:recipient != scope:actor
		scope:actor = {
			is_ai = no
			exists = var:surveil_target
			var:surveil_target = scope:recipient
		}
	}

	auto_accept = yes
	on_accept = {
		scope:actor = {
			if = {
				limit = { exists = var:surveil_target }
				remove_variable = surveil_target
			}
		}
		scope:recipient = {
			custom_tooltip = surveil_target_interaction_end_surveillance.tt
		}
		scope:recipient = {
			remove_list_variable = {
				name = players_surveilling_me
				target = scope:actor
			}
		}
	}

	is_available = {
		is_ai = no
	}
}
