title_decisions = {

#Envoyer une province
#Abandonné Titre
#Abandonné Revendication
#Créateur de titres
#Gestionnaire de titres
#Lieu Saint
#Change Coa
#Nomad
#Aventurier
	
####################################
####### Envoyer une province #######
####################################

	mark_title = {
		filter = all
		only_playable = yes
		
		from_potential = {
		    ai = no
			#independent = yes
			is_landed = yes
		}
		
		potential = {
		    owner = { character = FROM }
			NOT = { has_title_flag = send_title_flag }
			#lower_real_tier_than = DUKE
		}
		
		allow = { always = yes }
		
		effect = {
			set_title_flag = send_title_flag
		}
	}
	
	remove_mark_title = {
		filter = all
		only_playable = yes
		
		from_potential = {
		    ai = no
		}
		
		potential = {
		    owner = { character = FROM }
			#OR = { #Retire marque province vassal
			#    owner = { character = FROM }
			#	FROM = { is_liege_of = ROOT }
			#}
			has_title_flag = send_title_flag
		}
		
		allow = { always = yes }
		
		effect = {
			clr_title_flag = send_title_flag
		}
	}

###############################
####### Abandonné Titre #######
###############################

	title_abandoned = {
		filter = all
		
		from_potential = {
		    ai = no
			independent = yes
			is_landed = yes
			is_nomadic = no
		}
		
		potential = {
		    owner = { character = FROM }
			higher_real_tier_than = COUNT
			NOT = {
				title = k_papal_state
				title = e_hre
			}
		}
		
		allow = {
			always = yes
		}
		
		effect = {
			destroy_landed_title = THIS
			if = {
				limit = { tier = DUKE }
				custom_tooltip = { text = custom_destroying_this_title_200
					any_de_jure_vassal_title = {
						limit = {
							holder_scope = {
								NOT = { character = FROM }
								higher_real_tier_than = BARON
								vassal_of = FROM
							}
						}
						holder_scope = {
							opinion = {
								modifier = opinion_destroyed_dj_liege_title
								who = FROM
							}
						}
					}
					FROM = {
						prestige = -200
					}
				}
			}
			else_if = {
				limit = { tier = KING }
				custom_tooltip = { text = custom_destroying_this_title_400
					any_de_jure_vassal_title = {
						limit = {
							holder_scope = {
								NOT = { character = FROM }
								higher_real_tier_than = BARON
								vassal_of = FROM
							}
						}
						holder_scope = {
							opinion = {
								modifier = opinion_destroyed_dj_liege_title
								who = FROM
							}
						}
					}
					FROM = {
						prestige = -400
					}
				}
			}
			else_if = {
				limit = { tier = EMPEROR }
				custom_tooltip = { text = custom_destroying_this_title_800
					any_de_jure_vassal_title = {
						limit = {
							holder_scope = {
								NOT = { character = FROM }
								higher_real_tier_than = BARON
								vassal_of = FROM
							}
						}
						holder_scope = {
							opinion = {
								modifier = opinion_destroyed_dj_liege_title
								who = FROM
							}
						}
					}
					FROM = {
						prestige = -800
					}
				}
			}
		}
	}

#########################################
####### Abandonné Revendication #########
#########################################
	
	abandoned_claim = {
		filter = all
		ai_target_filter = none
		only_playable = yes

		from_potential = {
			is_ruler = yes
		}
		
		potential = {
			claimed_by = FROM
		}
		
		allow = {
			OR = {
				tier = BARON
				tier = COUNT
				tier = DUKE
				tier = KING
				tier = EMPEROR
			}
		}
		
		effect = {
			if = {
				limit = { tier = COUNT }
				FROM = {
					prestige = -5
					piety = 5
				}
			}
			else_if = {
				limit = { tier = DUKE }
				FROM = {
					prestige = -10
					piety = 20
				}
			}
			else_if = {
				limit = { tier = KING }
				FROM = {
					prestige = -20
					piety = 35
				}
			}
			else_if = {
				limit = { tier = EMPEROR }
				FROM = {
					prestige = -40
					piety = 50
				}
			}
			holder_scope = {
				if = {
					limit = {
						NOT = { has_opinion_modifier = { who = FROM modifier = opinion_abandoned_claim } }
					}
					if = {
						limit = {
							OR = {
								ROOT = { is_contested = yes }
								vassal_of = FROM
							}
						}
						opinion = {
							who = FROM
							modifier = opinion_abandoned_claim
							multiplier = 2
							years = 20
						}
					}
					else = {
						opinion = {
							who = FROM
							modifier = opinion_abandoned_claim
							years = 20
						}
					}
				}
			}
			remove_claim = FROM
		}
		
		ai_will_do = {
			factor = 0
		}
	}

####################################
####### Créateur de titres #########
####################################

	tm_create_duchy = {
		from_potential = {
			ai = no
			independent = yes
		}
		
		potential = {
			real_tier = COUNT
			holder_scope = {
				same_realm = FROM
			}
		}
		
		allow = {
			FROM = {
				primary_title = {
					OR = {
						real_tier = DUKE
						real_tier = KING
						real_tier = EMPEROR
					}
				}
				wealth = 200
			}
		}
		
		effect = {
			create_title = {
				tier = DUKE
				landless = no
				temporary = no
				custom_created = yes
				holder = FROM
				base_title = ROOT
				copy_title_laws = yes
			}
			FROM = {
				wealth = -200
				prestige = 200
			}
		}
	}

	tm_create_kingdom = {
		from_potential = {
			ai = no
			independent = yes
		}
		
		potential = {
			real_tier = DUKE
			holder_scope = {
				same_realm = FROM
			}
		}
		
		allow = {
			FROM = {
				primary_title = {
					OR = {
						real_tier = KING
						real_tier = EMPEROR
					}
				}
				wealth = 400
				piety = 200
			}
		}
		
		effect = {
			create_title = {
				tier = KING
				landless = no
				temporary = no
				custom_created = yes
				holder = FROM
				base_title = ROOT
				copy_title_laws = yes
			}
			FROM = {
				wealth = -400
				piety = -200
				prestige = 400
			}
		}
	}
	
	tm_create_empire = {
		from_potential = {
			ai = no
			independent = yes
		}
		
		potential = {
			real_tier = KING
			holder_scope = {
				same_realm = FROM
			}
		}
		
		allow = {
			FROM = {
				primary_title = {
					OR = {
						real_tier = EMPEROR
					}
				}
				wealth = 800
				piety = 400
			}
		}
		
		effect = {
			create_title = {
				tier = EMPEROR
				landless = no
				temporary = no
				custom_created = yes
				holder = FROM
				base_title = ROOT
				copy_title_laws = yes
			}
			FROM = {
				wealth = -800
				piety = -400
				prestige = 800
			}
		}
	}

########################################
####### Gestionnaire de titres #########
########################################

	tm_designate_recipient_duchy = {
		from_potential = {
			ai = no
			independent = yes
		}
		
		potential = {
			real_tier = DUKE
			holder_scope = {
				same_realm = FROM
			}
		}
		
		allow = {
			OR = {
				custom_tooltip = {
					text = tm_tooltip_not_designated_duchy
					hidden_tooltip = {
						NOT = {
							has_title_flag = adjudication_duchy_recipient
						}
					}
				}
				custom_tooltip = {
					text = tm_tooltip_two_designated_duchy
					FROM = {
						any_realm_title = {
							count = 2
							has_title_flag = adjudication_duchy_recipient			
						}
					}
				}
			}
		}
		
		effect = {
			custom_tooltip = {
				text = tm_tooltip_is_designated_duchy
				hidden_tooltip = {
					FROM = {
						any_title_under = {
							limit = {
								real_tier = DUKE
								has_title_flag = adjudication_duchy_recipient
							}
							clr_title_flag = adjudication_duchy_recipient
						}
					}
					ROOT = { set_title_flag = adjudication_duchy_recipient }
				}
			}
		}
		revoke_allowed = {
			always = no
		}
	}
	
	tm_transfer_county_to_recipient_duchy = {
		from_potential = {
			ai = no
			independent = yes
		}
		
		potential = {
			real_tier = COUNT
			holder_scope = {
				same_realm = FROM
			}
		}
		
		allow = {
			FROM = {
				custom_tooltip = {
					text = tm_tooltip_any_duchy_is_designated
					hidden_tooltip = {
						any_realm_title = {
							has_title_flag = adjudication_duchy_recipient 
						}
					}
					NOT = {
						any_realm_title = {
							count = 2
							has_title_flag = adjudication_duchy_recipient
						}
					}
				}
				wealth = 100
			}
			dejure_liege_title = { NOT = { has_title_flag = adjudication_duchy_recipient } }
		}

		effect = {
			FROM = {
				any_title_under = {
					limit = {
						real_tier = DUKE
						has_title_flag = adjudication_duchy_recipient
					}
					custom_tooltip = {
						text = tm_tooltip_transfer
						hidden_tooltip = {
							ROOT = {
								de_jure_liege = PREV
							}
						}
					}
				}	
				wealth = -100
			}
		}
		
		revoke_allowed = {
			always = no
		}
	}
	
##########################
####### Lieu Saint #######
##########################

	set_holy_site_action = {
		filter = all
		ai_target_filter = none
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			ai = no
		}
		
		potential = {
			lower_tier_than = COUNT
		}
		
		allow = {
			NOT = { num_of_holy_sites = 7 }
			religion_authority = 0.5
			ROOT = { NOT = { is_holy_site = PREV } }
		}
		
		effect = {
			set_holy_site = catholic
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	remove_holy_site_action = {
		filter = all
		ai_target_filter = none
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			ai = no
		}
		
		potential = {
			is_holy_site = catholic
		}
		
		allow = {
			always = yes
		}
		
		effect = {
			remove_holy_site = catholic
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_hellenic_pagan_holy_site = {
		filter = demesne
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = hellenic_pagan }
			NOT = { religion = hellenic_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = hellenic_pagan }
			}
			OR = {
				is_holy_site = hellenic_pagan
				any_de_jure_vassal_title = {
					is_holy_site = hellenic_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = hellenic_pagan
			}
		}
		

		
		
		ai_will_do = {
			factor = 0
		}
	}
	
##########################
####### Change Coa #######
##########################

	reset_title_coa = {
		filter = realm_owned
		ai_target_filter = realm_owned
		ai_check_interval = 12
		
		from_potential = {
			is_nomadic = no
		}
		potential = {
			OR = {
				tier = DUKE
				tier = KING
				tier = EMPEROR
			}
			is_titular = no
			has_title_flag = custom_changed_coa
			owner = { character = FROM }
		}
		allow = {
			FROM = {
				war = no
				is_not_busy_trigger = yes
				has_regent = no
				is_incapable = no
			}
		}
		effect = {
			clr_title_flag = custom_changed_coa
			reset_coa = THIS
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	take_county_coa = {
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_nomadic = no
		}
		potential = {
			tier = COUNT
			dejure_liege_title = { owner = { character = FROM } }
		}
		allow = {
			is_occupied = no
			location = {
				NOT = { has_province_modifier = peasant_unrest }
			}
			FROM = {
				war = no
				is_not_busy_trigger = yes
				has_regent = no
				is_incapable = no
			}
		}
		effect = {
			dejure_liege_title = {
				set_coa = ROOT
				set_title_flag = custom_changed_coa
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	take_duchy_king_coa = {
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_nomadic = no
		}
		potential = {
			OR = {
				tier = DUKE
				tier = KING
			}
			dejure_liege_title = { owner = { character = FROM } }
			owner = { character = FROM }
		}
		allow = {
			FROM = {
				war = no
				is_not_busy_trigger = yes
				has_regent = no
				is_incapable = no
			}
		}
		effect = {
			dejure_liege_title = {
				set_coa = ROOT
				set_title_flag = custom_changed_coa
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
#####################
####### Nomad #######
#####################
	
	nomad_split_clan = {
		filter = owned
		ai_target_filter = none
		
		from_potential = {
			is_nomadic = yes
			ai = no
		}
		potential = {
			tier = COUNT
			owner = { character = FROM }
		}
		allow = {
			is_occupied = no
		}
		effect = {
			create_character = {
				random_traits = yes
				religion = ROOT
				culture = ROOT
				female = no
				age = 25
			}
			new_character = {
				grant_title = ROOT
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
##########################
####### Aventurier #######
##########################
	
	raiding_adventurer_title = {
		filter = all
		ai_target_filter = none
		
		from_potential = {
			ai = no
			OR = {
				government = adventurer_government
				primary_title = { has_title_flag = adventurer_title }
			}
		}
		
		potential = {
			tier = COUNT
			can_be_given_away = yes
			holder_scope = {
				NOT = { has_character_modifier = adventure_land_timer }
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			save_event_target_as = target_title
			holder_scope = { save_event_target_as = target_ruler }
			FROM = {
				character_event = { id = adventurer.26 }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

}