﻿purchase_freedom_interaction = {
	category = interaction_category_friendly
	common_interaction = yes
	desc = purchase_freedom_interaction.desc
	interface_priority = 80
	ai_frequency = 0
	
	
	is_shown = {
		scope:actor = {
			has_trait = slave
			has_relation_master = scope:recipient
		}
	}
	
	can_send = {
		scope:actor = {
			is_ai = no
			is_imprisoned = no
			gold >= 50
		}	
	}
	
	
	on_accept = {
		scope:actor = {
		 every_traveling_family_member = { limit = { has_trait = slave } 
		  rtr_release_slave_and_remove_relation_effect = yes	
		}
        pay_short_term_gold = {
					gold = 50
					target = scope:recipient
		}
		
		}
	
     }
	 
	 ai_frequency = 0

	ai_accept = {
		base = 15 # Try to make it 0 for most interactions

		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.1
			desc = AI_OPINION_REASON
		}
		modifier = {
			add = -10
			desc = purchase_property_interaction.lowbornopinion
			scope:actor = {
				dynasty = { has_dynasty_modifier = lowborn_modifier }
			}
		}
		modifier = {
			add = -10
			desc = PROCURE_ESTATE_GALLOWSBAIT_REASON
			scope:actor = {
				has_trait = gallowsbait
			}
		}
		#DIFFERENT FAITH FROM STATE FAITH (if recipient is state faith)
		modifier = {
			add = -5
			desc = PROCURE_ESTATE_STATE_FAITH_REASON
			scope:actor.faith = {
				NOT = {
					this = scope:recipient.top_liege.primary_title.state_faith
				}
			}
			scope:recipient.faith = {
				this = scope:recipient.top_liege.primary_title.state_faith
			}
		}
		#Your dynasty is pretty great actually
		modifier = {
			add = 10
			scope:actor.dynasty = {
				dynasty_prestige_level >= 4
				dynasty_prestige_level < 7
			}
			desc = PROCURE_ESTATE_DYNASTY_PRESTIGE_LEVEL_REASON
		}
		#Your dynasty is pretty great actually
		modifier = {
			add = 20
			scope:actor.dynasty = {
				dynasty_prestige_level >= 7
				dynasty_prestige_level < 10
			}
			desc = PROCURE_ESTATE_DYNASTY_PRESTIGE_LEVEL_REASON
		}
		#Your dynasty is pretty great actually
		modifier = {
			add = 30
			scope:actor.dynasty = { dynasty_prestige_level >= 10 }
			desc = PROCURE_ESTATE_DYNASTY_PRESTIGE_LEVEL_REASON
		}
		#You have a criminal background
		modifier = {
			add = -5
			desc = PROCURE_ESTATE_GALLOWSBAIT_REASON
			scope:actor = {
				has_trait = gallowsbait
				NOR = {
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value < 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value < 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value < 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value < 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value < 40
					}
				}
			}
		}
		modifier = {
			add = -20
			desc = PROCURE_ESTATE_GALLOWSBAIT_REASON
			scope:actor = {
				has_trait = gallowsbait
				OR = {
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value >= 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value >= 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value >= 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value >= 40
					}
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value >= 40
					}
				}
				NOR = {
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value < 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value < 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value < 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value < 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value < 80
					}
				}
			}
		}
		modifier = {
			add = -50
			desc = PROCURE_ESTATE_GALLOWSBAIT_REASON
			scope:actor = {
				has_trait = gallowsbait
				OR = {
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value >= 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value >= 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value >= 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value >= 80
					}
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value >= 80
					}
				}
			}
		}
		#You have an interesting claim within my realm
		#Needs gold
		modifier = {
			add = 10
			scope:recipient = {
				gold <= minor_gold_value
			}
			NOT = {
				scope:gold_option = yes
			}
			desc = PROCURE_ESTATE_NEEDS_GOLD_REASON
		}
	}
	 	
}