﻿namespace = autoPrison

autoPrison.0001 = {

	hidden = yes
	type = character_event

	# only if still active and imprison possible at all
	trigger = {
		has_global_variable = auto_prison_active
		NOT = { root = { has_character_flag = flag_hostile_actions_disabled_delay } }
	}

	# try again tomorrow
	on_trigger_fail = {

		if = {
			has_global_variable = auto_prison_active
			trigger_event = {
				id = autoPrison.0001
				days = 1
			}
		}

	}

	immediate = {
		# chose possible charactor for imprison
		random_living_character = {
			limit = {
				is_diplomatically_available = yes
				is_imprisoned = no
				root = {
					has_imprisonment_reason = prev
				}
				root = {
					allowed_to_imprison_character_trigger = { CHARACTER = prev }
				}
			}
			# open interaction window
			open_interaction_window = {
				interaction = imprison_interaction
				actor = root
				recipient = this
			}	
		}
		# try again in 5 days
		trigger_event = {
			id = autoPrison.0001
			days = 5
		}
	}
}