## Written by WKIII - "Court AI"
## Updated and continued by Cody Spring
title_decisions = {
	# Court AI switch:
	enable_court_ai = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			NOT = { has_title_flag = court_ai_enabled }
		}
		allow = { always = yes }
		effect = {
			set_title_flag = court_ai_enabled
		}
		ai_will_do = { factor = 0 }
	}
	disable_court_ai = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
		}
		allow = { always = yes }
		effect = {
			clr_title_flag = court_ai_enabled
		}
		ai_will_do = { factor = 0 }
	}
	# Minor titles:
	# court_ai_enable_minor_titles = {
		# filter = primary_title
		# from_potential = { ai = no }
		# potential = {
			# owner = { character = FROM }
			# has_title_flag = court_ai_enabled
			# NOT = { has_title_flag = court_ai_minor_titles }
		# }
		# allow = { always = yes }
		# effect = { set_title_flag = court_ai_minor_titles }
		# ai_will_do = { factor = 0 }
	# }
	# court_ai_disable_minor_titles = {
		# filter = primary_title
		# from_potential = { ai = no }
		# potential = {
			# owner = { character = FROM }
			# has_title_flag = court_ai_enabled
			# has_title_flag = court_ai_minor_titles
		# }
		# allow = { always = yes }
		# effect = { clr_title_flag = court_ai_minor_titles }
		# ai_will_do = { factor = 0 }
	# }
	# Discourage plotters:
	court_ai_enable_discourage_plotters = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_discourage_plotters }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_discourage_plotters }
		ai_will_do = { factor = 0 }
	}
	court_ai_disable_discourage_plotters = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_discourage_plotters
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_discourage_plotters }
		ai_will_do = { factor = 0 }
	}
	# Ransom Prisoners:
	court_ai_enable_ransom = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_ransom }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_ransom }
		ai_will_do = { factor = 0 }
	}
	court_ai_disable_ransom = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_ransom
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_ransom }
		ai_will_do = { factor = 0 }
	}
	# Demand gavelkind
	court_ai_enable_demand_gavelkind = {
		filter = primary_title
		from_potential = { ai = no has_dlc = "Reapers" }
		potential = {
			owner = { character = FROM is_feudal = yes is_vice_royalty = no }
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_demand_gavelkind }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_demand_gavelkind }
		ai_will_do = { factor = 0 }
	}
	court_ai_disable_demand_gavelkind = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_demand_gavelkind
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_demand_gavelkind }
		ai_will_do = { factor = 0 }
	}
	# Stargazing
	court_ai_enable_stargazing = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM society_member_of = hermetics }
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_stargazing }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_stargazing }
		ai_will_do = { factor = 0 }
		}
	court_ai_disable_stargazing = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_stargazing
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_stargazing }
		ai_will_do = { factor = 0 }
	}
	# Invite Carousing
	court_ai_enable_carousing = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM OR = { 
											has_focus = focus_carousing 
											trait = hedonist 
											trait = socializer
										} 
				}
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_carousing }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_carousing }
		ai_will_do = { factor = 0 }
		}
	court_ai_disable_carousing = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_carousing
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_carousing }
		ai_will_do = { factor = 0 }
	}
	# Find Seduction target
	court_ai_enable_seduction = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { 
				character = FROM
				has_focus = focus_seduction
			}
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_seduction }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_seduction }
		ai_will_do = { factor = 0 }
		}
	court_ai_disable_seduction = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_seduction
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_seduction }
		ai_will_do = { factor = 0 }
	}
	# Educating kids:
	court_ai_enable_kids_education = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			NOT = { has_title_flag = court_ai_kids_education }
		}
		allow = { always = yes }
		effect = { set_title_flag = court_ai_kids_education }
		ai_will_do = { factor = 0 }
	}
	court_ai_disable_kids_education = {
		filter = primary_title
		from_potential = { ai = no }
		potential = {
			owner = { character = FROM }
			has_title_flag = court_ai_enabled
			has_title_flag = court_ai_kids_education
		}
		allow = { always = yes }
		effect = { clr_title_flag = court_ai_kids_education }
		ai_will_do = { factor = 0 }
	}
	
	
}
