﻿enslave_interaction = {
	interface_priority = 120
	common_interaction = yes
	category = interaction_category_prison
	icon = prison

	desc = enslave_interaction.desc
	
	ai_targets = {
		ai_recipients = prisoners
	}
	
	ai_frequency = 25
	
	ai_potential = {
		is_at_war = no
	}
	
	ai_will_do = {
		base = 0
		
		opinion_modifier = {
			trigger = {
				NOT = { scope:actor = scope:recipient }
			}
			opinion_target = scope:recipient
			multiplier = -1
		}
		
		ai_value_modifier = {
			ai_compassion = -1
		}
		modifier = {
			add = -10
			ai_compassion >= low_positive_ai_value
			scope:recipient = { is_adult = no }
		}
		modifier = {
			add = 100
			has_execute_reason = scope:recipient
		}
		modifier = {
		    add = 50
			has_imprisonment_reason = scope:recipient
	    }
		modifier = {
		    add = 200
			scope:recipient = { has_trait = escaped_slave }
		}	

	}
	
	is_shown = {
		scope:recipient = {
			is_imprisoned_by = scope:actor
			OR = {
			AND = {
			 OR = {
			 is_lowborn = yes
			 AND = {
			 exists = dynasty
			 dynasty = { has_dynasty_modifier = lowborn_modifier }
			 }
			 }
			}
			OR = { has_trait = peasant_leader has_trait = populist_leader } # so rebels can be enslaved
			 
		    }
			is_ruler = no
			NOT = { has_trait = slave }
		}
		OR = { scope:actor = { is_ai = no } scope:recipient = { is_ai = no } } #Only allow if the recipient or actor is a player
	}

	is_valid_showing_failures_only = {
		scope:recipient = { is_busy_in_events_localised = yes } #Prisoner
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
		scope:recipient = {
			custom_description = {
				text = "currently_being_tortured"
				NOT = { has_character_flag = is_being_tortured }
			}
		}
	}

	on_accept = {
	    scope:actor = { add_gold = 5 }
	    random_ruler = { limit = { in_diplomatic_range = scope:actor } save_scope_as = master }
		scope:recipient = { rtr_enslave_no_family_effect = yes set_relation_grudge = { target = scope:actor reason = sold_into_slavery } }
	}

	auto_accept = yes
}