targeted_decisions = {

#Former une marche
#Devenir une marche
#Intégrer une marche
#Devenir un État Tributaire
#Former un État Tributaire
#Visite Cellule
#Aventurier
#Mérovingien
#Envoyer à la garde varègue
#Jurer fidélité
#Emprisonner
#Esclave
#Artéfact Décisions
#Demander un prisonnier
#Envoyer un prisonnier
#Entrevue Diplomatique
#Accord Commercial
#Vrai Pére
#Banquet
#Assassiné
#Pacte Non-Agression
#Invité a la chasse
#Discussion Religieuse
#Envoyer un titre
#Envoyé Or
#Abdiquer
#Castrate Decision
#Blinding Decision
#Send Courtier
#Ancestor
#Mariage forcé
#Transférer le vasselage
#Offrir une Faveur
#Vendre une Faveur
#Offrir de se joindre à la guerre
#Inviter à rejoindre ma guerre
#Empire Dynastique
#Cardinal
#Investiture
#Aide à la guerre
#Participation à la croisade
#Indulgence
#Bénéficiaire papal
#IA Assistant
#Dynastie
#Republique
#Mercenaire
#Pardon

#################################
####### Former une marche #######
#################################

    form_a_union_autonomous = {
		filter = vassals
		ai_target_filter = vassals
		ai_check_interval = 1
		diplomacy_icon = GFX_union_0_icon
		
		from_potential = {
			OR = {
			    tier = DUKE
				tier = KING
                tier = EMPEROR
            }
			is_ruler = yes
		}

		potential = {
			NOT = { de_jure_liege_or_above = FROM }
			NOT = { character = FROM }
			is_ruler = yes
			NOT = { has_character_flag = form_union_autonomous_flag }
			NOT = { has_character_flag = form_union_tributary_flag }
			is_tributary = no
			NOT = { has_landed_title = d_papal_guards }
			OR = {
				FROM = { is_patrician = no }
				AND = {
					FROM = { is_patrician = yes }
					is_patrician = no
				}
			}
		}
		
		allow = {
			war = no
			FROM = {
			    war = no
				independent = yes
				prisoner = no
				is_liege_of = ROOT
				is_tribal = no
				is_nomadic = no
				#OR = {
				#    is_liege_of = ROOT
				#	ROOT = {
				#		pays_tribute_to = FROM
				#	    is_tributary = { type = permanent }
				#	}
				#}
			}
			ROOT = { NOT = { reverse_has_opinion_modifier = { who = FROM modifier = opinion_refuse_union_autonomous } } }
		}
		
        effect = {
			FROM = {
				character_event = { id = union_autonomous.1 days = 3 }
			}
			set_character_flag = form_union_autonomous_flag
        }
		
		ai_will_do = {
            factor = 1
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				ROOT = {
					OR = {
						FROM = { de_jure_vassal_or_below = ROOT }
						capital_scope = {
							OR = {
								is_connected_to = {
									sub_realm = no
									target = realm_capital
									sea_gap = yes
									land_gap = yes
									naval_distance = 200
								}
							}
						}
						any_realm_province = {
							is_connected_to = {
								sub_realm = no
								target = realm_capital
								sea_gap = yes
								land_gap = yes
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				ROOT = { tier = KING }
			}
			modifier = {
				factor = 1.5
				ROOT = { tier = DUKE }
			}
			modifier = {
				factor = 0
				ROOT = { NOT = { culture_group = FROM } }
			}
			modifier = {
				factor = 0
				ROOT = { NOT = { religion = FROM } }
			}
			modifier = {
				factor = 0
				ROOT = {
					is_merchant_republic = yes
				}
			}
		}
	}

##################################
####### Devenir une marche #######
##################################

	ask_union_autonomous = {
		filter = all
		ai_target_filter = independent_rulers
		ai_check_interval = 24
		diplomacy_icon = GFX_union_1_icon

		from_potential = {
			NOT = { has_character_flag = ask_union_autonomous_flag }
			OR = {
                tier = DUKE
                tier = KING
				tier = COUNT
            }
			is_ruler = yes
		}
		
		potential = {
			NOT = { de_jure_liege_or_above = FROM }
			NOT = { character = FROM }
			is_ruler = yes
			NOT = { is_tributary = { type = union_autonomous } }
		}
		
		allow = {
			FROM = {
				independent = yes
				is_tributary = no
				mercenary = no
				prisoner = no
				war = no
				OR = {
				    lower_tier_than = ROOT
					ROOT = { diplomatic_interview_trigger = yes }
				}
			}
			ROOT = {
				independent = yes
				NOT = { pays_tribute_to = FROM }
				mercenary = no
				prisoner = no
				is_tribal = no
				is_nomadic = no
			}
		}
		
		effect = {
			FROM = {
			    character_event = { id = union_autonomous.8 days = 1 random = 3 }
				set_character_flag = ask_union_autonomous_flag
			}
		}
		
		ai_will_do = {
			factor = 0
			modifier = {
				factor = 0.1
			}
			modifier = {
				factor = 0
				FROM = {
					is_tribal = yes
				}
			}
			modifier = {
				factor = 0
				FROM = {
					is_nomadic = yes
				}
			}
			modifier = {
				factor = 0
				FROM = {
					NOT = {
						AND = {
							culture = ROOT
							religion = ROOT
						}
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = imbecile
						trait = slothful
						trait = incapable
						trait = ambitious
						trait = proud
						trait = paranoid
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					is_rival = ROOT
				}
			}
			modifier = {
				factor = 0
				FROM = {
					relative_realm_size = {
						who = ROOT
						size >= 0.5
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					distance_from_realm = {
						who = ROOT
						value >= 250
					}
				}
			}
			modifier = { 
				factor = 0.5 
				ruled_years = 25
			}
			modifier = { 
				factor = 0.5 
				FROM = { tier = KING }
			}
			modifier = {
				factor = 0.5
				FROM = {
					NOT = {
						opinion = {
							who = ROOT
							value = 0
						}
					}
				}
			}
			modifier = {
				factor = 2
				FROM = {
					dynasty = ROOT
				}
			}
			modifier = {
				factor = 2
				FROM = {
					relative_realm_size = {
						who = ROOT
						size <= 0.25
					}
				}
			}
		}
	}

###################################
####### Intégrer une marche #######
###################################

	integrate_union = {
		filter = independent_rulers
		ai_target_filter = independent_rulers
		ai_check_interval = 48
		diplomacy_icon = GFX_union_1_icon
		
		from_potential = {
		    is_ruler = yes
		}
		
		potential = {
			pays_tribute_to = FROM
			is_tributary = { type = union_autonomous }
			is_ruler = yes
			is_landed = yes
			NOT = { has_character_flag = integrate_union_autonomous_flag }
		}
		
		allow = {
			FROM = { prisoner = no }
			ROOT = {
				lower_tier_than = FROM
				war = no
				independent = yes
				NOT = { has_character_modifier = union_timer }
			}
		}
		
		effect = {
			FROM = { character_event = { id = union_autonomous.12 days = 1 random = 3 } }
			set_character_flag = integrate_union_autonomous_flag
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
			}
			modifier = {
				factor = 5
				ROOT = {
					OR = {
						FROM = { de_jure_vassal_or_below = ROOT }
						capital_scope = {
							OR = {
								is_connected_to = {
									sub_realm = no
									target = realm_capital
									sea_gap = yes
									land_gap = yes
									naval_distance = 200
								}
							}
						}
						any_realm_province = {
							is_connected_to = {
								sub_realm = no
								target = realm_capital
								sea_gap = yes
								land_gap = yes
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				FROM = {
					trait = ambitious
					trait = administrator
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					trait = diligent
					trait = shrewd
				}
			}
			modifier = {
				factor = 0
				FROM = {
					trait = incapable
					trait = slothful
					trait = content
				}
			}
		}
	}
	
##########################################
####### Devenir un État Tributaire #######
##########################################

	ask_tributary_state = {
		filter = all
		ai_target_filter = independent_rulers
		ai_check_interval = 24
		diplomacy_icon = GFX_union_2_icon

		from_potential = {
			NOT = { has_character_flag = ask_tributary_state_flag }
			OR = {
				tier = COUNT
                tier = DUKE
                tier = KING
            }
			is_landed = yes
		}
		
		potential = {
			NOT = { de_jure_liege_or_above = FROM }
			NOT = { character = FROM }
			is_ruler = yes
		}
		
		allow = {
			FROM = {
				independent = yes
				is_tributary = no
				mercenary = no
				war = no
				prisoner = no
			}
			ROOT = {
				independent = yes
				NOT = { pays_tribute_to = FROM }
				mercenary = no
				prisoner = no
				is_within_diplo_range = FROM
			}
		}
		
		effect = {
			FROM = {
			    character_event = { id = union_autonomous.18 days = 1 random = 3 }
				set_character_flag = ask_tributary_state_flag
			}
		}
		
		ai_will_do = {
			factor = 0
			modifier = {
				factor = 0.1
			}
			modifier = {
				factor = 0
				FROM = {
					NOT = {
						culture_group = ROOT
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = imbecile
						trait = slothful
						trait = incapable
						trait = ambitious
						trait = proud
						trait = paranoid
						trait = greedy
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					is_rival = ROOT
				}
			}
			modifier = {
				factor = 0
				FROM = {
					relative_realm_size = {
						who = ROOT
						size >= 0.5
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					distance_from_realm = {
						who = ROOT
						value >= 250
					}
				}
			}
			modifier = { 
				factor = 0 
				FROM = {
					NOT = { religion = ROOT }
					trait = zealous
				}
			}
			modifier = { 
				factor = 0.5 
				ruled_years = 25
			}
			modifier = { 
				factor = 0.5 
				FROM = { tier = KING }
			}
			modifier = {
				factor = 0.5
				FROM = {
					NOT = {
						opinion = {
							who = ROOT
							value = 0
						}
					}
				}
			}
			modifier = { 
				factor = 2 
				FROM = { is_primary_war_defender = yes }
			}
			modifier = {
				factor = 2
				FROM = {
					relative_realm_size = {
						who = ROOT
						size <= 0.25
					}
				}
			}
		}
	}
	
#########################################
####### Former un État Tributaire #######
#########################################
	
	form_a_union_tribut = {
		filter = vassals
		ai_target_filter = vassals
		ai_check_interval = 1
		diplomacy_icon = GFX_union_2_icon
		
		from_potential = {
			OR = {
			    tier = DUKE
				tier = KING
                tier = EMPEROR
            }
			is_ruler = yes
		}

		potential = {
			NOT = { de_jure_liege_or_above = FROM }
			NOT = { character = FROM }
			is_ruler = yes
			NOT = { has_character_flag = form_union_autonomous_flag }
			NOT = { has_character_flag = form_union_tributary_flag }
			is_tributary = no
			NOT = { has_landed_title = d_papal_guards }
			OR = {
				FROM = { is_patrician = no }
				AND = {
					FROM = { is_patrician = yes }
					is_patrician = no
				}
			}
		}
		
		allow = {
			war = no
			FROM = {
			    war = no
				independent = yes
				prisoner = no
				is_liege_of = ROOT
				conditional_tooltip = {
					trigger = {
						capital_scope = {
							NOT = {
								region = world_europe
							}
						}
					}
					prestige = 200
					TECH_MAJESTY = 2
				}
				conditional_tooltip = {
					trigger = {
						capital_scope = {
							region = world_europe
						}
					}
					prestige = 200
					TECH_MAJESTY = 4
				}
			}
				ROOT = { NOT = { reverse_has_opinion_modifier = { who = FROM modifier = opinion_refuse_union_tribut } } }
		}
		
        effect = {
			FROM = {
				character_event = { id = union_autonomous.22 days = 3 }
			}
			set_character_flag = form_union_tributary_flag
        }
		
		ai_will_do = {
            factor = 1
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				ROOT = {
					OR = {
						FROM = { de_jure_vassal_or_below = ROOT }
						capital_scope = {
							OR = {
								is_connected_to = {
									sub_realm = no
									target = realm_capital
									sea_gap = yes
									land_gap = yes
									naval_distance = 200
								}
							}
						}
						any_realm_province = {
							is_connected_to = {
								sub_realm = no
								target = realm_capital
								sea_gap = yes
								land_gap = yes
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				ROOT = { tier = DUKE }
			}
			modifier = {
				factor = 2
				ROOT = { NOT = { culture_group = FROM } }
			}
			modifier = {
				factor = 2
				ROOT = { NOT = { religion = FROM } }
			}
			modifier = {
				factor = 2
				ROOT = {
					is_merchant_republic = yes
				}
			}
		}
	}
	
##############################
####### Visite Cellule #######
##############################

	cell_visit = {
	    filter = court
		ai_target_filter = court
		ai_check_interval = 12
		diplomacy_icon = GFX_cell_visit
		
		from_potential = {
			is_ruler = yes
			age = 16
			OR = {
			    trait = lustful
				trait = cruel
			}
			NOT = { trait = celibate }
			NOT = { trait = chaste }
		}
	
		potential = {
			host = { character = FROM }
			OR = {
				prisoner = yes
				is_enslaved = yes
			}
			age = 14
			NOT = { has_character_modifier = cell_visit }
			NOT = { has_character_flag = cell_visit_flag }
		}
		
		allow = {
		    FROM = {
			    prisoner = no
			    is_incapable = no
			    NOT = { is_inaccessible_trigger = yes }
			}
			OR = {
			    AND = {
				    FROM = { trait = homosexual }
					ROOT = { same_sex = FROM }
				}
				AND = {
				    FROM = { trait = homosexual }
					ROOT = { NOT = { same_sex = FROM } }
				}
				AND = {
				    FROM = { NOT = { trait = homosexual } }
					ROOT = { same_sex = FROM }
				}
				AND = {
				    FROM = { NOT = { trait = homosexual } }
					ROOT = { NOT = { same_sex = FROM } }
				}
			}
		}
		
		effect = {
			hidden_tooltip = {
			    ROOT = { set_character_flag = cell_visit_flag }
			    FROM = { character_event = { id = cellvisit.1 } }
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
			}
			modifier = {
				factor = 0
				OR = {
					reverse_opinion = { who = FROM value = 40 }
					FROM = { NOT = { piety = 100 } }
					FROM = { LIEGE = { dynasty = ROOT } }
				}
			}
			modifier = {
				factor = 0
				FROM = {
					NOR = {
						trait = cruel
						trait = impaler
						trait = wroth
						is_rival = ROOT
						trait = arbitrary
						trait = paranoid
						trait = deceitful
						trait = proud
						trait = lunatic
						trait = possessed
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = kind
						trait = just
						trait = patient
						trait = shy
						trait = greedy
					}
				}
			}
			modifier = {
				factor = 10
				ROOT = {
					OR = {
						trait = groomed
						trait = fair
						NOT = {
						    trait = uncouth
							trait = ugly
							trait = hunchback
							trait = harelip
							trait = dwarf
							trait = disfigured
							trait = leper
						}
					}
				}
			}
		}
	}
	
##########################
####### Aventurier #######
##########################

    become_adventurer = {
	    filter = self
		ai_target_filter = none
		
		potential = {
			ai = no
			is_landed = yes
			is_adult = yes
			prisoner = no
			NOT = { primary_title = { has_title_flag = adventurer_title } }
		}
		
		allow = {
			always = yes
		}
		
		effect = {
			character_event = { id = adventurer.1 }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
    raise_adventurer_troops = {
	    filter = all
	    ai_target_filter = none
		diplomacy_icon = GFX_raise_adventurer_troops
		
		from_potential = {
		    ai = no
			is_republic = no
			OR = {
				is_landed = no
				primary_title = { has_title_flag = adventurer_title }
			}
			prisoner = no
			NOT = { is_foe = ROOT }
			NOT = { has_character_flag = raise_adventurer_troops_flag }
		}
		
		potential = {
			NOT = { is_foe = FROM }
		}
		
		allow = {
			FROM = {
				wealth = 100
				NOT = {
					war_with = ROOT
					relative_power = {
						who = ROOT
						power = 1
					}
				}
			}
			ROOT = {
				is_ruler = yes
			}
			AND = {
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_timer_1
				    }
				}
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_timer_2
				    }
				}
			}
		}
		
		effect = {
		    FROM = { set_character_flag = raise_adventurer_troops_flag }
			ROOT = { letter_event = { id = adventurer.9 days = 1 } }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	raise_adventurer_special_troops = {
	    filter = all
	    ai_target_filter = none
		diplomacy_icon = GFX_raise_adventurer_special_troops
		
		from_potential = {
		    ai = no
			is_republic = no
			is_landed = yes
			primary_title = { has_title_flag = adventurer_title }
			prisoner = no
			NOT = { is_foe = ROOT }
			NOT = { has_character_flag = raise_adventurer_special_troops_flag }
		}
		
		potential = {
			NOT = { is_foe = FROM }
		}
		
		allow = {
			FROM = {
				wealth = 300
				NOT = { war_with = ROOT }
			}
			ROOT = {
				is_ruler = yes
				independent = yes
			}
			AND = {
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_timer_1
				    }
				}
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_timer_2
				    }
				}
			}
		}
		
		effect = {
		    FROM = { set_character_flag = raise_adventurer_special_troops_flag }
			ROOT = { letter_event = { id = adventurer.13 days = 1 } }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	raise_adventurer_fleet = {
	    filter = all
	    ai_target_filter = none
		diplomacy_icon = GFX_raise_adventurer_fleet
		
		from_potential = {
		    ai = no
			is_republic = no
			OR = {
				is_landed = no
				primary_title = { has_title_flag = adventurer_title }
			}
			prisoner = no
			NOT = { is_foe = ROOT }
			NOT = { has_character_flag = raise_adventurer_fleet_flag }
		}
		
		potential = {
			NOT = { is_foe = FROM }
		}
		
		allow = {
			FROM = {
				wealth = 100
				NOT = { war_with = ROOT }
			}
			ROOT = {
			    #opinion = { who = FROM value = 20 }
				is_ruler = yes
				any_demesne_province = { is_coastal = yes }
			}
			AND = {
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_timer_1
				    }
				}
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_timer_2
				    }
				}
			}
		}
		
		effect = {
		    FROM = { set_character_flag = raise_adventurer_fleet_flag }
			ROOT = { letter_event = { id = adventurer.12 days = 1 } }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	adventurer_mercenary_deff = {
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_adventurer_mercenary
	
		from_potential = {
			ai = no
			is_republic = no
			prisoner = no
			is_landed = no
			war = no
			NOT = { is_foe = ROOT }
		}
	
		potential = {
			NOT = { is_foe = FROM }
			is_primary_war_defender = yes
		}
	
		allow = {
			FROM = { NOT = { war_with = ROOT } }
			war = yes
			is_primary_war_defender = yes
			NOT = {
				is_liege_of = FROM
				is_foe = FROM
			}
		}
		
		effect = {
			FROM = { character_event = { id = adventurer.15 days = 1 } }
		}
		
		ai_will_do = {
    		factor = 0
 		}
	}
	
	adventurer_mercenary_att = {
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_adventurer_mercenary
	
		from_potential = {
			ai = no
			is_republic = no
			prisoner = no
			is_landed = no
			war = no
			NOT = { is_foe = ROOT }
		}
	
		potential = {
			NOT = { is_foe = FROM }
			is_primary_war_attacker = yes
		}
	
		allow = {
			FROM = { NOT = { war_with = ROOT } }
			war = yes
			is_primary_war_attacker = yes
			NOT = {
				is_liege_of = FROM
				is_foe = FROM
			}
		}
		
		effect = {
			FROM = { character_event = { id = adventurer.19 days = 1 } }
		}
		
		ai_will_do = {
    		factor = 0
 		}
	}
	
	adventurer_pillage = {
		filter = self
		ai_target_filter = none
	
	
		potential = {
			ai = no
			is_republic = no
			is_landed = no
			prisoner = no
		}
	
		allow = {
		    always = yes
		}
		
		effect = {
			any_army = {
	        	set_looting = yes
	        }
		}
		
		ai_will_do = {
    		factor = 0
 		}
	}
	
	adventurer_marriage = {
		filter = all
		ai_target_filter = none
	
	
		from_potential = {
			ai = no
			is_republic = no
			is_landed = no
			is_married = no
			is_marriage_adult = yes
			prisoner = no
		}
		
		potential = {
			is_married = no
		}
	
		allow = {
			OR = {
				ROOT = { is_lover = FROM }
				is_consort = yes
			}
		}
		
		effect = {
			add_spouse = FROM
		}
		
		ai_will_do = {
    		factor = 0
 		}
	}
	
	adventurer_abdicate = {
		filter = self
		ai_target_filter = none
	
		potential = {
			ai = no
			is_republic = no
			is_landed = no
		}
	
		allow = {
		    always = yes
		}
		
		effect = {
		    current_heir = {
		    		character_event = { id = ABD.1 days = 3 random = 3 }
		    }
		    set_character_flag = has_abdicated
	        prestige = -250
        }
		
		ai_will_do = {
    		factor = 0
 		}
	}
	
	no_vassal_adventurer = {
	    filter = all
	    ai_target_filter = none
		
		from_potential = {
		    ai = no
			is_republic = no
			OR = {
				is_landed = no
				primary_title = { has_title_flag = adventurer_title }
			}
			prisoner = no
			NOT = { is_foe = ROOT }
		}
		
		potential = {
			NOT = { is_foe = FROM }
		}
		
		allow = {
			is_liege_of = FROM
		}
		
		effect = {
			FROM = { set_defacto_liege = THIS }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	adventurer_holding = {
	    filter = self
		
		potential = {
			ai = no
			is_republic = no
			is_landed = no
			prisoner = no
		}
	
		allow = {
			FROM = {
				wealth = 100
				in_command = yes
			}
		    location = {
				has_empty_holding = yes
			}
		}
		
		effect = {
			wealth = -100
			location = {
				build_holding = {
					type = tribal
					holder = FROM
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
###########################
####### Mérovingien #######
###########################
	
	play_bloodline_merovingian = {
		filter = all
		diplomacy_icon = GFX_empire_dynastique_icon
		
		from_potential = {
			ai = no
		}
		
		potential = {
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_merovingian
			}
			NOT = { has_character_flag = merovingian_play_flag }
		}
		
		allow = {
			total_years_played <= 1
    	}
		
        effect = {
			FROM = {
				character_event = { id = adventurer.24 }
			}
			ROOT = { set_character_flag = merovingian_play_flag }
		}
		
		ai_will_do = {
			factor = 0
		}
		
    }
	
##########################################
####### Envoyer à la garde varègue #######
##########################################

	send_to_varangian_guard = {
		only_playable = yes
		filter = dynasty
		ai_target_filter = dynasty
		has_dlc = "The Old Gods"

		from_potential = {
			is_playable = yes
			culture_group = north_germanic
			has_global_flag = varangian_guard_founded
		}
		
		potential = {
			is_child_of = FROM
			is_liege_or_above = FROM
			culture_group = north_germanic
			# Taken from oldgods_various_events.txt row 562.
			OR = { #Updated: New gender check for ROOT, to account for special circumstances...
				has_game_rule = { # Game rules are all on!
					name = gender
					value = all
				}
				AND = { # The Old Gods version...
					is_female = no
					gender_equality_trigger = no
				}
				AND = { # Status of women version, allowing women in...
					is_female = yes
					liege = { primary_title = { has_law = status_of_women_4 } }
				}
				AND = { # Boys always dream of fighting, when not explicitly blocked from it
					is_female = no
					NOT = { has_religion_feature = religion_matriarchal } 
				}
				AND = { # Enatic Clans version (no boys allowed)...
					is_female = yes
					has_religion_feature = religion_matriarchal
				}
			}
			NOR = {
				trait = varangian
				has_character_modifier = wants_varangian
				has_character_modifier = serving_varangian
				is_landed = yes
			}
		}

		allow = {
			is_adult = yes
			martial = 10
			NOT = {
				trait = incapable
			}
			custom_tooltip = {
				text = send_to_varangian_guard_custom_tooltip
				hidden_tooltip = {
					NOR = {
						trait = varangian 
						has_character_modifier = wants_varangian 
						has_character_modifier = serving_varangian
					}
				}
			}
			FROM = {
				wealth = 100
			}
		}

		effect = {
			d_varangian_guard = {
				holder_scope = {
					ROOT = {
						move_character = PREV
					}
				}
			}
			FROM = {
				wealth = -100
			}
			ROOT = {
				set_character_flag = wants_varangian
			}
			hidden_tooltip = {
				ROOT = { 
					character_event = { id = TOG.3108 days = 1460 }
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.01
			}
		}
	}
	
##############################
####### Jurer fidélité #######
##############################
	
	vassalize_decision = {
	    filter = all
		ai_target_filter = none
		ai_check_interval = 24
		
		from_potential = {
			ai = no
			is_republic = no
			is_landed = no
		    independent = yes
		}
		
		potential = {
			#independent = yes
			is_ruler = yes
			higher_tier_than = FROM
		}
		
		allow = {
			independent = yes
			FROM = {
				war = no
				independent = yes
				prisoner = no
			}
		}
		
		effect = {
			letter_event = { id = vassalize.1 days = 3 }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
###########################
####### Emprisonner #######
###########################
	
	imprison_decision = {
	    filter = sub_realm
	    ai_target_filter = sub_realm
		ai_check_interval = 12
		
		is_high_prio = yes
		
		from_potential = {
		    ai = yes
			prisoner = no
			is_incapable = no
			in_seclusion = no
		}
		
		potential = {
			prisoner = no
		}
		
		allow = {
			FROM = {
				is_liege_of = ROOT
				is_inaccessible_trigger = no
			}
			ROOT = {
				is_inaccessible_trigger = no
			}
			FROM = {
				OR = {
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder_of_spouse
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder_of_child
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder_of_parent
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder_of_sibling
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder_of_vassal
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder_of_spouse_vassal
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = attempted_murder
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_spouse_slayer
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_murder_attempt
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_killed_close_kin
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_killed_father
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_hajj_attempt_murder
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_fatwa_target
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_refused_order
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_castrated_me
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_blinded_me
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_castrated_family
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_castrated_close_kin
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_blinded_family
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_blinded_close_kin
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_witch
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_takfir
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_attempted_abduction
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_unfaithful_wife
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_unfaithful_husband_crime
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_cuckolded
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_killed_lover
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_heresiarch
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_infidel
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_deviant
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_illegitimate
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_cultist
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_dw
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_traitor
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_charge_slanderer
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = abuse_of_office
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_tortured_me
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_tortured_family
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_tortured_close_kin
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_mutilated_me
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_mutilated_family
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_mutilated_close_kin
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_thief
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_outlawed_society
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_accused_apostate
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_dishonorable
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_traitor
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_rebel_traitor
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_regicide_traitor
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_cell_visit_me
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_cell_visit_child
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_cell_visit_kin
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_cell_visit_spouse
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = opinion_seized_artifact_tyranny
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = seized_artifact
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = seized_artifact_dynastic
					}
					has_opinion_modifier = {
						who = ROOT
						modifier = seized_artifact_inheritance
					}
				}
			}
		}
		
		effect = {
			ROOT = { character_event = { id = imprison.1 days = 1 } }
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = imbecile   #Imbécile
						trait = slothful   #Paresseux
						trait = incapable  #incapable
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					OR = {
						trait = slow       #Lent
						trait = dull	   #Simplet
						trait = craven	   #Lache
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					OR = {
						trait = wroth     #Colère
						trait = ambitious #Ambitieux
						trait = deceitful #Fourbe
						trait = just      #Juste
					}
				}
			}
			modifier = {
				factor = 2
				FROM = {
					OR = {
						trait = genius    #Génie
						trait = shrewd    #Rusé
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					NOT = { culture_group = ROOT }
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					trait = zealous
					NOT = { religion = ROOT }
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					dynasty = ROOT
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					realm_levy_diff = { 
						who = ROOT
						value >= 1000
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					realm_levy_diff = { 
						who = ROOT
						value <= 100
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					opinion = {
						who = ROOT
						value = 50
					}
				}
			}
			modifier = {
				factor = 0.7
				FROM = {
					opinion = {
						who = ROOT
						value = 25
					}
				}
			}
			modifier = {
				factor = 1.2
				FROM = {
					NOT = {
						opinion = {
							who = ROOT
							value = 0
						}
					}
				}
			}
		}
	}
	
#######################
####### Esclave #######
#######################

	claim_slave_decision = {
		filter = self
		ai_target_filter = self
		ai_check_interval = 12
		diplomacy_icon = GFX_slavery_decision
		
		third_party_filter = home_court_including_me
        ai_third_party_filter = home_court_including_me
		third_party = ROOT
		show_third_party_potential = no
		
		only_playable = yes

		potential = {
			is_playable = yes
			prisoner = no
			any_host_courtier = {
				count = 1
				prisoner = yes
				is_ruler = no
			}
		}
		
		third_party_potential = {
			FROMFROM = {
				prisoner = yes
				host = { character = FROM }
				is_ruler = no
			}
		}
		
		allow = {
			is_adult = yes
			num_of_prisoners = 1
			NOT = { trait = in_hiding }
			slavery_trigger = yes
		}

		effect = {
			FROM = {
				save_event_target_as = slaver
			}
			FROMFROM = {
				save_event_target_as = slave
			}
			if = {
				limit = {
					FROM = { check_variable = { which = slaves_count value > 0 } }
				}
				custom_tooltip = { text = custom_count_slave_1 }
			}
			
			if = {
				limit = {
					FROM = { check_variable = { which = slaves_count value <= 0 } }
				}
				custom_tooltip = { text = custom_count_slave_2 }
			}

			slavery_opinion_effect = yes
			
			FROMFROM = {
				show_scope_change = no
				
				enslave_effect = yes
				hidden_tooltip = {
					imprison = no
					set_defacto_liege = FROM
					move_character = FROM
					force_host = FROM
					if = {
						limit = { FROM = { ai = no } }
						character_event = { id = slave.4 }
					}
				}
				custom_tooltip = { text = custom_claim_slave }
				slaver_count = yes
			}
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.2
			}
			modifier = {
				factor = 0
				FROMFROM = { NOT = { age = 5 } }
			}
			modifier = {
				factor = 0.4
				FROMFROM = { NOT = { age = 8 } }
			}
			modifier = {
				factor = 0
				FROMFROM = { is_close_relative = FROM }
			}
			modifier = {
				factor = 0
				FROM = { opinion = { who = FROMFROM value = 60 } }
			}
			modifier = {
				factor = 0
				FROMFROM = {
					has_character_flag = slave_punished_by_@LIEGE 
				}
			}
			modifier = {
				factor = 0.8
				FROM = { opinion = { who = FROMFROM value = 20 } }
				FROM = { NOT = { opinion = { who = FROMFROM value = 60 } } }
			}
			modifier = {
				factor = 0.4
				FROMFROM = { dynasty = FROM }
			}
			modifier = {
				factor = 1.6
				FROMFROM = { is_lowborn = yes }
			}
			modifier = {
				factor = 0.7
				FROM = { religion = norse_pagan }
			}
			modifier = {
				factor = 0.7
				FROMFROM = { religion = FROM }
			}
			modifier = {
				factor = 0.9
				FROMFROM = { is_female = yes }
			}
			modifier = {
				factor = 0.5
				FROM = {
					OR = {
						trait = kind
						trait = temperate
						trait = just
						NOT = { ai_ambition = -39 }
					}
				}
			}
			modifier = {
				factor = 5
				FROM = {
					OR = {
						trait = cruel
						trait = impaler
						trait = wroth
						is_rival = FROMFROM
						trait = arbitrary
						trait = lunatic
						trait = possessed
					}
				}
			}
			modifier = {
				factor = 2
				FROM = {
					OR = {
						ai_greed = 100
						ai_ambition = 40
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						FROMFROM = {
							has_education_diplomacy_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_diplomacy_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						FROMFROM = {
							has_education_martial_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_martial_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						FROMFROM = {
							has_education_stewardship_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_stewardship_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						FROMFROM = {
							has_education_intrigue_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_intrigue_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						FROMFROM = {
							religion = FROM
							has_education_learning_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									religion = FROM
									has_education_learning_trigger = yes
									count = 5
								}
							}
						}
					}
				}
			}
		}
	}
	
	claim_slave_decision_bis = {
		filter = all
		ai_target_filter = none
		ai_check_interval = 12
		diplomacy_icon = GFX_slavery_decision
		
		only_playable = yes

		from_potential = {
			is_playable = yes
			prisoner = no
			slavery_trigger = yes
			any_host_courtier = {
				count = 1
				prisoner = yes
				is_ruler = no
			}
		}
		
		potential = {
			ROOT = {
				prisoner = yes
				host = { character = FROM }
				is_ruler = no
			}
		}
		
		allow = {
			FROM = {
				is_adult = yes
				num_of_prisoners = 1
				NOT = { trait = in_hiding }
			}
		}

		effect = {
			FROM = {
				save_event_target_as = slaver
			}
			ROOT = {
				save_event_target_as = slave
			}
			if = {
				limit = {
					FROM = { check_variable = { which = slaves_count value > 0 } }
				}
				custom_tooltip = { text = custom_count_slave_1 }
			}
			
			if = {
				limit = {
					FROM = { check_variable = { which = slaves_count value <= 0 } }
				}
				custom_tooltip = { text = custom_count_slave_2 }
			}

			slavery_opinion_effect = yes
			
			ROOT = {
				show_scope_change = no
				
				enslave_effect = yes
				hidden_tooltip = {
					imprison = no
					set_defacto_liege = FROM
					move_character = FROM
					force_host = FROM
					if = {
						limit = { FROM = { ai = no } }
						character_event = { id = slave.4 }
					}
				}
				custom_tooltip = { text = custom_claim_slave }
				slaver_count = yes
			}
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.2
			}
			modifier = {
				factor = 0
				ROOT = { NOT = { age = 5 } }
			}
			modifier = {
				factor = 0.4
				ROOT = { NOT = { age = 8 } }
			}
			modifier = {
				factor = 0
				ROOT = { is_close_relative = FROM }
			}
			modifier = {
				factor = 0
				FROM = { opinion = { who = ROOT value = 60 } }
			}
			modifier = {
				factor = 0
				ROOT = {
					has_character_flag = slave_punished_by_@LIEGE 
				}
			}
			modifier = {
				factor = 0.8
				FROM = { opinion = { who = ROOT value = 20 } }
				FROM = { NOT = { opinion = { who = ROOT value = 60 } } }
			}
			modifier = {
				factor = 0.4
				ROOT = { dynasty = FROM }
			}
			modifier = {
				factor = 1.6
				ROOT = { is_lowborn = yes }
			}
			modifier = {
				factor = 0.7
				FROM = { religion = norse_pagan }
			}
			modifier = {
				factor = 0.7
				ROOT = { religion = FROM }
			}
			modifier = {
				factor = 0.9
				ROOT = { is_female = yes }
			}
			modifier = {
				factor = 0.5
				FROM = {
					OR = {
						trait = kind
						trait = temperate
						trait = just
						NOT = { ai_ambition = -39 }
					}
				}
			}
			modifier = {
				factor = 5
				FROM = {
					OR = {
						trait = cruel
						trait = impaler
						trait = wroth
						is_rival = ROOT
						trait = arbitrary
						trait = lunatic
						trait = possessed
					}
				}
			}
			modifier = {
				factor = 2
				FROM = {
					OR = {
						ai_greed = 100
						ai_ambition = 40
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						ROOT = {
							has_education_diplomacy_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_diplomacy_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						ROOT = {
							has_education_martial_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_martial_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						ROOT = {
							has_education_stewardship_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_stewardship_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						ROOT = {
							has_education_intrigue_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									has_education_intrigue_trigger = yes
									count = 5
								}
							}
						}
					}
					AND = {
						ROOT = {
							religion = FROM
							has_education_learning_trigger = yes
						}
						FROM = {
							NOT = {
								any_host_courtier = {
									religion = FROM
									has_education_learning_trigger = yes
									count = 5
								}
							}
						}
					}
				}
			}
		}
	}
	
	free_slave_decision = {
		filter = home_court
		ai_target_filter = home_court
		ai_check_interval = 12
		diplomacy_icon = GFX_slavery_decision
		
		only_playable = yes

		from_potential = {
			is_playable = yes
			prisoner = no
		}

		potential = {
			trait = slave_trait
			host = { character = FROM }
		}

		allow = {
			is_enslaved = yes
			is_ruler = no
			is_landed = no
		}

		effect = {
			FROM = {
				save_event_target_as = liberator
			}
			if = {
				limit = {
					FROM = { check_variable = { which = free_slave_count value > 0 } }
				}
				custom_tooltip = { text = custom_count_slave_free_1 }
			}
			
			if = {
				limit = {
					FROM = { check_variable = { which = free_slave_count value <= 0 } }
				}
				custom_tooltip = { text = custom_count_slave_free_2 }
			}
			free_slave_count = yes
			free_slave_effect = yes
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.01
			}
			modifier = {
				factor = 0
				FROM = { is_slaver_group = yes }
				NOR = {
					AND = {
						has_minor_title = title_commander
						check_variable = { which = slave_year_count value >= 15 }
						prestige = 500
					}
					AND = {
						is_close_relative = yes
						prisoner = no
					}
				}
			}
			modifier = {
				factor = 2
				is_close_relative = yes
				prisoner = no
			}
			modifier = {
				factor = 2
				dynasty = FROM
			}
			modifier = {
				factor = 2
				FROM = { 
					NOR = {
						religion_group = pagan_group
						religion_group = muslim
						religion_group = indian_group
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = { 
					OR = {
						trait = kind
						trait = humble
						trait = trusting
						trait = charitable
					}
				}
			}
			modifier = {
				factor = 0
				FROM = { 
					OR = {
						trait = cruel
						trait = impaler
						trait = wroth
						is_rival = FROMFROM
						trait = arbitrary
						trait = lunatic
						trait = possessed
					}
				}
				NAND = {
					FROM = { trait = lunatic }
					is_close_relative = yes
					prisoner = no
				}
			}
		}
	}
	
	request_slave_decision = {
		filter = all
		ai_target_filter = none
		ai_check_interval = 24
		diplomacy_icon = GFX_slavery_decision
		
		third_party_filter = home_court
        third_party = ROOT
		
        third_party_potential = {
            FROMFROM = {
				is_enslaved = yes
                prisoner = no
				is_ruler = no
				NOT = { has_character_modifier = mark_slave_tag }
			}
        }
		
		potential = {
		    prisoner = no
			is_ruler = yes
			in_seclusion = no
			NOT = { has_character_flag = request_slave_flag }
		}
		
		allow = {
			show_only_failed_conditions = yes
			ROOT = {
				custom_tooltip = {
					text = custom_has_slave
					any_courtier = {
						count = 1
						is_enslaved = yes
						prisoner = no
						is_ruler = no
					}
				}
			}
			prisoner = no
			in_seclusion = no
		}
		
		third_party_score = {
			factor = 25
			
			calculate_slave_price = yes
		}
		
        effect = {
		    hidden_tooltip = {
		        FROMFROM = {
			    	add_character_modifier  = {
			    		name = mark_slave_tag
			    		duration = 360
			    	}
			    }
			    FROM = {
					character_event = { id = slave.9 days = 1 }
					set_character_flag = request_slave_flag
				}
		    }
		}
		
		ai_will_do = {
			factor = 0
		}
    }
	
	send_slave_decision = {
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_slavery_decision
		
		third_party_filter = home_court
        third_party = FROM
		
        third_party_potential = {
            FROMFROM = {
                is_enslaved = yes
				prisoner = no
				is_ruler = no
				NOT = { has_character_modifier = mark_slave_tag }
			}
        }
		
		from_potential = {
		    prisoner = no
			is_ruler = yes
			in_seclusion = no
		}
		
		potential = {
		    prisoner = no
			is_ruler = yes
		}
		
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				custom_tooltip = {
					text = custom_has_slave
					any_host_courtier = {
						count = 1
						is_enslaved = yes
						prisoner = no
						is_ruler = no
					}
				}
			}
			in_seclusion = no
		}
		
        effect = {
		    hidden_tooltip = {
		        FROMFROM = {
			    	add_character_modifier  = {
			    		name = mark_slave_tag
			    		duration = 360
			    	}
			    }
			    FROM = {
					slaver_count = yes
					character_event = { id = slave.5 days = 1 }
				}
		    }
		}
		
		ai_will_do = {
			factor = 0
		}
    }
	
	mark_slave_decision = {
	    filter = home_court
		diplomacy_icon = GFX_slavery_decision
		
		from_potential = {
		    ai = no
			prisoner = no
		}
		
		potential = {
			is_enslaved = yes
			host = { character = FROM }
			NOT = { has_character_flag = slave_not_work }
		}
		
		allow = {
		}
		
		effect = {
			ROOT = { set_character_flag = slave_not_work }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	unmark_slave_decision = {
	    filter = home_court
		diplomacy_icon = GFX_slavery_decision 
		
		from_potential = {
		    ai = no
			prisoner = no
		}
		
		potential = {
			is_enslaved = yes
			has_character_flag = slave_not_work
			host = { character = FROM }
		}
		
		allow = {
		}
		
		effect = {
			ROOT = { clr_character_flag = slave_not_work }
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
##################################
####### Artéfact Décisions #######
##################################

	girdle_of_aphrodite_power = {
		filter = all
		ai_target_filter = realm
		ai_check_interval = 24
		diplomacy_icon = GFX_charm_decision
		
		only_playable = yes
		
		from_potential = {
			OR = {
				religion_openly_hellenic_or_reformed_trigger = yes
				culture = greek
				culture = roman
			}
			has_artifact = girdle_of_aphrodite
			any_artifact = {
				artifact_type = girdle_of_aphrodite
				is_artifact_active = yes
			}
			NOT = { has_character_flag = girdle_of_aphrodite_flag }
		}
		
		potential = {
			is_female = no
			is_lover = no
		}
	
		allow = {
			ROOT = {
				is_adult = yes
				is_female = no
				is_incapable = no
				in_seclusion = no
				prisoner = no
				NOT = { trait = travelling }
				NOT = { trait = kow_tow_travels }
				NOT = { trait = on_pilgrimage }
			}
			FROM = {
				is_incapable = no
				in_seclusion = no
				prisoner = no
				NOT = { trait = travelling }
				NOT = { trait = kow_tow_travels }
				NOT = { trait = on_pilgrimage }
			}
		}
		effect = {
			FROM = { set_character_flag = girdle_of_aphrodite_flag }
			ROOT = { character_event = { id = artefact.48 days = 1 } }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				FROM = { NOT = { trait = lustful } }
			}
			modifier = {
				factor = 0
				FROM = { age >= 40 }
			}
		}
	}
	
	retrieve_artifact = {
		filter = court
		ai_target_filter = court
		ai_check_interval = 24
		third_party_filter = artifacts
		ai_third_party_filter = artifacts
		third_party = ROOT
		
		only_playable = yes
		
		from_potential = { is_playable = yes }
		
		potential = {
			num_of_artifacts = 1
			any_artifact = { any_artifact_owner = { dynasty = FROM } }
		}
		
		third_party_potential = {
			FROMFROM = {
				any_artifact_owner = {
					OR = {
						character = FROM
						dynasty = FROM
					}
				}
			}
		}
		
		third_party_allow = {
			FROMFROM = {
				any_artifact_owner = { dynasty = FROMFROM }
			}
		}
		
		allow = {
			ROOT = {
				custom_tooltip = {
					text = retrieve_artifact_allow
					prisoner = yes
					host = { character = FROM }
				}
			}
			FROM = {
				is_incapable = no
				prisoner = no
			}
		}
		
		effect = {
			FROM = {
				show_scope_change = no
				ROOT = {
					show_scope_change = no
					FROMFROM = { 
						transfer_artifact = {
							from = PREV
							to = PREVPREV
						}
					}
				}	
			}
			ROOT = {
				opinion = { who = FROM modifier = seized_artifact }
				add_rival = FROM
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
			}
		}
	}

	seize_artifact = {
		filter = court
		ai_target_filter = court
		ai_check_interval = 24
		third_party_filter = artifacts
		ai_third_party_filter = artifacts
		third_party = ROOT
		show_third_party_potential = yes
		
		only_playable = yes
		
		from_potential = { is_playable = yes }
		
		potential = {
			num_of_artifacts = 1
			prisoner = yes
		}
		
		third_party_potential = {
			FROMFROM = {
				show_scope_change = no
				is_artifact_equipped = yes
				NOT = {
					custom_tooltip = { text = seize_artifact_allow has_artifact_flag = blacklist }
				}
			}
		}
		
		allow = {
			FROM = {
				is_incapable = no
				prisoner = no
			}
			ROOT = {
				custom_tooltip = {
					text = seize_artifact_allow3
					prisoner = yes
					host = { character = FROM }
				}
			}
		}
		
		effect = {
			FROM = {
				ROOT = {
					show_scope_change = no
					FROMFROM = {
						transfer_artifact = {
							from = PREV
							to = PREVPREV
						}
					}
				}
				custom_tooltip = {
					text = seize_artifact_effect2
					any_vassal = {
						opinion = {
							modifier = opinion_seized_artifact_tyranny
							who = PREV
						}
					}
				}
				
				if = {
					limit = { NOT = { trait = greedy } }
					random = {
						chance = 75
						add_trait = greedy
					}
				}
				if = {
					limit = { NOT = { trait = deceitful } }
					random = {
						chance = 75
						add_trait = deceitful
					}
				}
				if = {
					limit = { trait = honest }
					random = {
						chance = 75
						remove_trait = honest
					}
				}
				if = {
					limit = { trait = just }
					random = {
						chance = 75
						remove_trait = just
					}
				}
				if = {
					limit = { trait = kind }
					random = {
						chance = 50
						remove_trait = kind
					}
				}
				if = {
					limit = { trait = charitable }
					random = {
						chance = 50
						remove_trait = charitable
					}
				}
				if = {
					limit = { trait = temperate }
					random = {
						chance = 50
						remove_trait = temperate
					}
				}
				if = {
					limit = { trait = zealous }
					random = {
						chance = 50
						remove_trait = zealous
					}
				}
			}
			custom_tooltip = {
				text = seize_artifact_effect3
				ROOT = {
					opinion = { who = FROM modifier = seized_artifact }
					add_rival = FROM
					current_heir = { opinion = { who = FROM modifier = seized_artifact_inheritance } }
					any_dynasty_member = {
						limit = { is_alive = yes }
						opinion = { who = FROM modifier = seized_artifact_dynastic }
					}
				}
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.2
			}
			modifier = {
				factor = 2
				FROM = { trait = greedy }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = envious }
			}
			modifier = {
				factor = 2
				FROM = { trait = ambitious }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = deceitful }
			}
			modifier = {
				factor = 0
				FROM = { trait = temperate }
			}
			modifier = {
				factor = 0
				FROM = { trait = charitable }
			}
			modifier = {
				factor = 0
				FROM = { trait = kind }
			}
			modifier = {
				factor = 0
				FROM = { trait = content }
			}
			modifier = {
				factor = 0
				FROM = { trait = honest }
			}
			modifier = {
				factor = 0
				FROM = { trait = just }
			}
			modifier = {
				factor = 0
				FROM = { trait = zealous }
			}
		}
	}
	
	send_son_to_zun = {
		filter = dynasty
		ai_target_filter = dynasty
		ai_check_interval = 24
		only_playable = yes
		
		from_potential = {
			religion = zun_pagan_reformed
			is_landed = yes
			NOT = { has_landed_title = d_zun_warriors }
		}
		
		potential = {
			dynasty = FROM
			liege = { character = FROM }
		}
	
		allow = {
			is_title_active = d_zun_warriors
			ROOT = {
				is_child_of = FROM
				is_adult = yes
				is_female = no
				is_landed = no
				is_incapable = no
				in_seclusion = no
				religion = zun_pagan_reformed
				NOT = { has_bottom_tier_education_trait_trigger = yes }
				OR = {
					diplomacy = 10
					martial = 10
					stewardship = 10
					intrigue = 10
					learning = 10
				}
			}
		}
		
		effect = {
			FROM = { piety = 100 }
			ROOT = { character_event = { id = artefact.27 } }
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.2
			}
			modifier = {
				factor = 2
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 0
				FROM = { trait = cynical }
			}
			modifier = {
				factor = 0
				ROOT = { is_primary_heir = yes }
			}
		}
	}
	
######################################
####### Demander un prisonnier #######
######################################

	request_prisoner = {
		filter = all
		ai_target_filter = none
		ai_check_interval = 24
		diplomacy_icon = GFX_send_prisoner_icon
		
		third_party_filter = all
        third_party = ROOT
		
        third_party_potential = {
            FROMFROM = {
			    host = { character = ROOT }
                prisoner = yes
				NOT = { has_character_modifier = mark_prisoner_tag }
			}
        }
		
		potential = {
		    prisoner = no
			is_ruler = yes
			NOT = { has_character_flag = request_prisoner_flag }
		}
		
		allow = {
			show_only_failed_conditions = yes
			ROOT = {
				custom_tooltip = {
					text = custom_has_prisoner
					any_courtier = {
						count = 1
						prisoner = yes
						host = { character = ROOT }
					}
				}
			}
			is_within_diplo_range = FROM
			in_seclusion = no
		}
		
		third_party_score = {
			factor = 25
			
			calculate_prisoner_price = yes
		}
		
        effect = {
		    hidden_tooltip = {
		        FROMFROM = {
			    	add_character_modifier  = {
			    		name = mark_prisoner_tag
			    		duration = 360
			    	}
			    }
			    FROM = {
					character_event = { id = send.1 days = 1 }
					set_character_flag = request_prisoner_flag
				}
		    }
		}
		
		ai_will_do = {
			factor = 0
		}
    }

#####################################
####### Envoyer un prisonnier #######
#####################################

	send_prisoner = {
		filter = all
		ai_target_filter = none
		ai_check_interval = 24
		diplomacy_icon = GFX_send_prisoner_icon
		
		third_party_filter = home_court
        third_party = FROM
		
        third_party_potential = {
            FROMFROM = {
				host = { character = FROMFROM }
                prisoner = yes
				NOT = { has_character_modifier = mark_prisoner_tag }
			}
        }
		
		from_potential = {
		    prisoner = no
			is_ruler = yes
			in_seclusion = no
		}
		
		potential = {
		    prisoner = no
			is_ruler = yes
		}
		
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				custom_tooltip = {
					text = custom_has_prisoner
					any_host_courtier = {
						count = 1
						prisoner = yes
					}
				}
			}
			is_within_diplo_range = FROM
			in_seclusion = no
		}
		
        effect = {
		    hidden_tooltip = {
		        FROMFROM = {
			    	add_character_modifier  = {
			    		name = mark_prisoner_tag
			    		duration = 360
			    	}
			    }
			    FROM = { character_event = { id = send.10 days = 1 } }
		    }
		}
		
		ai_will_do = {
			factor = 0
		}
    }
	
#####################################
####### Entrevue Diplomatique #######
#####################################

	ask_diplomatic_interview = { # Demander
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_0_icon 
		
		from_potential = {
		    ai = no
			age = 16
			NOT = { 
				has_character_flag = ask_diplomatic_interview_flag
				trait = diplomatic_interview
			}
		}
		
		potential = {
		    ai = no
			age = 16
			NOT = {
			    reverse_has_opinion_modifier = { who = FROM modifier = host_diplomatic_interview }
				has_character_flag = ask_diplomatic_interview_flag
			}
		}
		
		allow = {
            FROM = {
			    is_inaccessible_trigger_A = no
				is_incapable = no
				prisoner = no
			}
			ROOT = {
			    is_inaccessible_trigger_A = no
				is_incapable = no
				prisoner = no
			}
    	}
		
        effect = {
		hidden_tooltip = {
		    FROM = {
			    set_character_flag = ask_diplomatic_interview_flag
				character_event = { id = ADI.01 days = 1 }
			}
		}
		}
    }
	
	quit_diplomatic_interview = { # Quitter
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_rp_mod_ADI_1_icon
		
		from_potential = {
		    trait = diplomatic_interview
			ai = no
		}
		
		potential = {
		    NOT = { trait = diplomatic_interview }
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    hidden_tooltip = {
		    FROM = { 
			    remove_trait = diplomatic_interview
				clr_character_flag = diplomatic_interview_army_flag
				remove_opinion = { who = ROOT modifier = target_diplomatic_interview }
				remove_opinion = { who = ROOT modifier = host_diplomatic_interview }
				any_opinion_modifier_target = { remove_opinion = { who = FROMFROM modifier = counterpart_diplomatic_interview } }
				clear_persistent_event_target = target_diplomatic_interview_1
				hidden_tooltip = { set_variable = { which = SCR value = 0 } }
			}
			ROOT = {
			    letter_event = { id = ADI.14 }
				remove_opinion = { who = FROM modifier = target_diplomatic_interview }
				remove_opinion = { who = FROM modifier = host_diplomatic_interview }
				clear_persistent_event_target = target_diplomatic_interview_2
				hidden_tooltip = { set_variable = { which = SCR value = 0 } }
			}
			any_opinion_modifier_target = {
                limit = {
                    reverse_has_opinion_modifier = {
                        who = FROMFROM
                        modifier = counterpart_diplomatic_interview
                    }
                }
                reverse_remove_opinion = {
                    who = FROMFROM
                    modifier = counterpart_diplomatic_interview
                }
            }
			}
		}
    }
	
	fired_diplomatic_interview = { # Expulsé
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_rp_mod_ADI_1_icon
		
		from_potential = {
		    NOT = { trait = diplomatic_interview }
		    ai = no
		}
		
		potential = {
		    trait = diplomatic_interview
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    hidden_tooltip = {
		    ROOT = { 
			    remove_trait = diplomatic_interview
				clr_character_flag = diplomatic_interview_army_flag
				letter_event = { id = ADI.15 }
				remove_opinion = { who = FROM modifier = target_diplomatic_interview }
				remove_opinion = { who = FROM modifier = host_diplomatic_interview }
				any_opinion_modifier_target = { remove_opinion = { who = ROOT modifier = counterpart_diplomatic_interview } }
				clear_persistent_event_target = target_diplomatic_interview_1
				hidden_tooltip = { set_variable = { which = SCR value = 0 } }
			}
			FROM = {
			    remove_opinion = { who = ROOT modifier = target_diplomatic_interview }
				remove_opinion = { who = ROOT modifier = host_diplomatic_interview }
				clear_persistent_event_target = target_diplomatic_interview_2
				hidden_tooltip = { set_variable = { which = SCR value = 0 } }
			}
			any_opinion_modifier_target = {
                limit = {
                    reverse_has_opinion_modifier = {
                        who = ROOT
                        modifier = counterpart_diplomatic_interview
                    }
                }
                reverse_remove_opinion = {
                    who = ROOT
                    modifier = counterpart_diplomatic_interview
                }
            }
			}
		}
    }
	
	pst_diplomatic_interview = { # Présentation
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_rp_mod_ADI_9_icon
		
		third_party_filter = all
        third_party = ROOT
		
        third_party_potential = {
            FROMFROM = {
			    reverse_has_opinion_modifier = { who = FROMFROM modifier = host_diplomatic_interview }
				NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = counterpart_diplomatic_interview } }
			}
        }
		
		from_potential = {
		    NOT = { trait = diplomatic_interview }
		    ai = no
		}
		
		potential = {
		    trait = diplomatic_interview
			diplomatic_interview_trigger = yes
			any_character = { reverse_has_opinion_modifier = { who = FROM modifier = host_diplomatic_interview } NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = counterpart_diplomatic_interview } } count = 2 }
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    hidden_tooltip = {
		        FROMFROM = {
				    opinion = {
			            who = ROOT
			            modifier = counterpart_diplomatic_interview
			            months = 999
		            }
				}
				ROOT = {
				    opinion = {
			            who = FROMFROM
			            modifier = counterpart_diplomatic_interview
			            months = 999
		            }
				}
			}
		}
    }
	
	stop_pst_diplomatic_interview = { # Stop Présentation
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_rp_mod_ADI_9_icon
		
		third_party_filter = all
        third_party = ROOT
		
        third_party_potential = {
            FROMFROM = {
			    reverse_has_opinion_modifier = { who = ROOT modifier = counterpart_diplomatic_interview }
			}
        }
		
		from_potential = {
		    NOT = { trait = diplomatic_interview }
		    ai = no
		}
		
		potential = {
		    trait = diplomatic_interview
			diplomatic_interview_trigger = yes
			
			any_character = { reverse_has_opinion_modifier = { who = FROM modifier = host_diplomatic_interview } reverse_has_opinion_modifier = { who = ROOT modifier = counterpart_diplomatic_interview } count = 1 }
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    hidden_tooltip = {
		        FROMFROM = {
				    remove_opinion = {
			            who = ROOT
			            modifier = counterpart_diplomatic_interview
			            months = 999
		            }
				}
				ROOT = {
				    remove_opinion = {
			            who = FROMFROM
			            modifier = counterpart_diplomatic_interview
			            months = 999
		            }
				}
			}
		}
    }

#################################
####### Accord Commercial #######
#################################

    ac_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_2_icon
		
		from_potential = {
		    ai = no
			capital_scope = {
			    NOT = { has_province_modifier = commercial_pact }
		    }
			NOT = { has_character_flag = ask_ac_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			capital_scope = {
			    NOT = { has_province_modifier = commercial_pact }
		    }
			NOT = { has_character_flag = ask_ac_diplomatic_interview_flag }
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_ac_diplomatic_interview_flag }
			ROOT = { character_event = { id = ADI.17 days = 1 } }
		}
    }
	
	quit_ac_diplomatic_interview = {
		filter = all
		ai_target_filter = none
		diplomacy_icon = GFX_rp_mod_ADI_2_icon
		
		from_potential = {
		    ai = no
		}
		
		potential = {
		    ai = no
			
		    FROM = {
			    has_opinion_modifier = {
                    who = ROOT
                    modifier = ac_diplomatic_interview_opinion_improved_relations
                }
			}
			
			ROOT = {
			    has_opinion_modifier = {
                    who = FROM
                    modifier = ac_diplomatic_interview_opinion_improved_relations
                }
			}
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    FROM = {
			    capital_scope = {
				    remove_province_modifier = commercial_pact
				}
				remove_opinion = { who = ROOT modifier = ac_diplomatic_interview_opinion_improved_relations }
			}
			ROOT = {
			    capital_scope = {
				    remove_province_modifier = commercial_pact
				}
				remove_opinion = { who = FROM modifier = ac_diplomatic_interview_opinion_improved_relations }
			}
		}
    }

#########################
####### Vrai Pére #######
#########################

	real_father_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_6_icon
		
		from_potential = {
		    ai = no
		}
		
		potential = {
		    ai = no
            ROOT = {
                is_father_real_father = no
            }
			real_father = { character = FROM }
			NOT = { has_character_flag = reveal_real_father_diplomatic_interview_flag }
			diplomatic_interview_trigger = yes
        }
		
		allow = {
		    always = yes
    	}
		
        effect = {
			ROOT = {
			    set_character_flag = reveal_real_father_diplomatic_interview_flag
			    character_event = { id = ADI.18 days = 1 }
			}
		}
    }

#######################
####### Banquet #######
#######################
	
	banquet_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_4_icon
		
		from_potential = {
		    ai = no
			NOT = { trait = diplomatic_interview }
			is_incapable = no
			NOT = { has_character_flag = ask_banquet_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			NOT = { has_character_modifier = banquet_diplomatic_interview_tag }
			is_incapable = no
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_banquet_diplomatic_interview_flag }
		    ROOT = { character_event = { id = ADI.21 days = 1 } }
		}
    }
	
#########################
####### Assassiné #######
#########################
	
	killed_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_7_icon
		
		from_potential = {
		    ai = no
			NOT = { has_character_flag = ask_killed_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			FROM = { NOT = { has_opinion_modifier = { who = ROOT modifier = counterpart_diplomatic_interview } } }
			NOT = { has_character_flag = ask_killed_diplomatic_interview_flag }
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    FROM = { 
				wealth = 350
			}
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_killed_diplomatic_interview_flag wealth = -350 }
		    ROOT = { character_event = { id = ADI.24 days = 1 } }
		}
    }
	
#################################
####### Pacte Non-Agression #####
#################################
	
	non_aggression_pact_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_8_icon
		
		from_potential = {
		    ai = no
			NOT = { has_character_flag = ask_non_aggression_pact_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			NOT = { has_non_aggression_pact_with = FROM }
			NOT = { has_character_flag = ask_non_aggression_pact_diplomatic_interview_flag }
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_non_aggression_pact_diplomatic_interview_flag }
		    ROOT = { character_event = { id = ADI.25 days = 1 } }
		}
    }
	
##################################
####### Invité a la chasse #######
##################################

    hunt_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_4_icon
		
		from_potential = {
		    ai = no
			NOT = { trait = diplomatic_interview }
			is_incapable = no
			NOT = { has_character_flag = ask_hunt_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			NOT = { has_character_modifier = hunt_diplomatic_interview_tag }
			is_incapable = no
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_hunt_diplomatic_interview_flag }
		    ROOT = { character_event = { id = ADI.33 days = 1 } }
		}
    }
	
#####################################
####### Discussion Religieuse #######
#####################################

    religious_discussion_diplomatic_interview = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_10_icon
		
		from_potential = {
		    ai = no
			is_incapable = no
			NOT = { has_character_flag = ask_religious_discussion_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			NOT = { has_character_modifier = religious_discussion_diplomatic_interview_tag }
			is_incapable = no
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    OR = {
			    FROM = {
			        trait = zealous
			    	NOT = { religion = ROOT }
			    }
				ROOT = {
			        trait = sympathy_christendom
			    	FROM = { religion_group = christian }
			    }
				ROOT = {
			        trait = sympathy_indian
			    	FROM = { religion_group = indian_group }
			    }
				ROOT = {
			        trait = sympathy_islam
			    	FROM = { religion_group = muslim }
			    }
				ROOT = {
			        trait = sympathy_judaism
			    	FROM = { religion_groupn = jewish_group }
			    }
				ROOT = {
			        trait = sympathy_pagans
			    	FROM = { religion_group = pagan_group }
			    }
				ROOT = {
			        trait = sympathy_zoroastrianism
			    	FROM = { religion_group = zoroastrian_group }
			    }
			}
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_religious_discussion_diplomatic_interview_flag }
		    ROOT = { character_event = { id = ADI.36 days = 1 } }
		}
    }
	
################################
####### Envoyer un titre #######
################################
	
    send_mark_title = {
		filter = all
		diplomacy_icon = GFX_rp_mod_ADI_11_icon
		
		from_potential = {
		    ai = no
			is_incapable = no
			NOT = { has_character_flag = ask_send_mark_title_diplomatic_interview_flag }
		}
		
		potential = {
		}
		
		allow = {
			ROOT = {
				is_incapable = no
				OR = {
					AND = {
						is_ruler = yes
						independent = yes
					}
					AND = {
						is_ruler = yes
						OR = {
							tier = FROM
							higher_tier_than = FROM
						}
					}
					host = { character = FROM }
					liege = { character = FROM }
				}
			}
            custom_tooltip = { text = CUSTOM_OPT_1
			    any_landed_title = {
			        has_title_flag = send_title_flag
					owner = { character = FROM }
			    }
			}
    	}
		
        effect = {
		    FROM = { set_character_flag = ask_send_mark_title_diplomatic_interview_flag }
			ROOT = { letter_event = { id = ADI.48 days = 1 } }
		}
    }

#########################
####### Envoyé Or #######
#########################

	send_player_gold = {
		filter = all
		diplomacy_icon = GFX_rp_mod_SPG_icon
		
		from_potential = {
		    wealth = 25
			ai = no
			NOT = { has_character_flag = sendplayergold }
		}
		
		potential = {
		    always = yes
		}
		
		allow = {
            always = yes
    	}
		
        effect = {
		    FROM = { set_character_flag = sendplayergold }
			FROM = { character_event = { id = SPG.01 } }
		}
    }
	
#########################
####### Abdiquer ########
#########################
	
	abdicate_decisions = {
		filter = self
		ai_target_filter = self
		ai_check_interval = 12
		
		is_high_prio = yes

		potential = {
		    OR = {
				is_feudal = yes
				is_tribal = yes
			}
			is_landed = yes
			is_adult = yes
			OR = {
				AND = {
					primary_title = { tier = KING }
					NOT = {
						any_demesne_title = {
							kingdom = { has_law = succ_gavelkind }
						}
					}
				}
				AND = {
					primary_title = { tier = EMPEROR }
					NOT = {
						any_demesne_title = {
							empire = { has_law = succ_gavelkind }
						}
					}
				}
				AND = {
					NOT = { primary_title = { higher_tier_than = DUKE } }
					NOT = {
						primary_title = {
							has_law = succ_gavelkind
						}
					}
				}
				has_landed_title = k_papal_state
			}
			current_heir = {
			    NOT = { has_character_flag = has_abdicated }
			}
			NOT = { has_character_flag = has_abdicated }
		}

		allow = {
		    trait = content
			prisoner = no
			NOT = { trait = imbecile }
		    NOT = { trait = lunatic }
		    NOT = { trait = possessed }
			OR = {
			    AND = {
				    trait = content
					OR = {
						trait = craven
						trait = depressed
					}
					NOT = { trait = envious }
					NOT = { trait = ambitious }
					NOT = { trait = greedy }
					NOT = { trait = paranoid }
					age = 20
				}
				AND = {
				    trait = content
					OR = {
					    trait = shy
						trait = craven
						trait = depressed
						trait = stressed
					}
					NOT = { trait = envious }
					NOT = { trait = ambitious }
					NOT = { trait = greedy }
					age = 40
				}
				AND = {
				    trait = content
					OR = {
					    trait = shy
						trait = craven
						trait = depressed
						trait = stressed
					}
					NOT = { trait = envious }
					NOT = { trait = greedy }
					age = 50
				}
				AND = {
				    trait = content
					OR = {
					    trait = shy
						trait = craven
						trait = depressed
						trait = stressed
					}
					NOT = { trait = envious }
					age = 60
				}
			}
		}
		
		effect = {
		    current_heir = {
		    		character_event = { id = ABD.1 days = 3 random = 3 }
		    }
		    set_character_flag = has_abdicated
	        prestige = -250
        }
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
			}
		}
	}
	
##################################
####### Castrate Decision ########
##################################

    castrate_action = {
		only_playable = yes
		filter = court
		ai_target_filter = court
		ai_check_interval = 12

		from_potential = {
			has_dlc = "Legacy of Rome"
			is_playable = yes
			trait = cruel
			NOT = {
				culture_group = byzantine
				culture_group = chinese_group
				any_owned_bloodline = {
					has_bloodline_flag = bloodline_castration
				}
			}
		}
	
		potential = {
			host = { character = FROM }
			OR = {
				prisoner = yes
				is_enslaved = yes
			}
			is_female = no
			NOT = { trait = eunuch }
		}
		
		allow = {
			OR = {
				prisoner = yes
				is_enslaved = yes
			}
		}
		
		effect = {
			hidden_tooltip = {
				if = {
					limit = { age = 16}
					FROM = {
						character_event = { id = LoR.832 }
					}
				}
				if = {
					limit = { NOT = { age = 16 } }
					FROM = {
						character_event = { id = LoR.834 }
					}
				}
				character_event = { id = LoR.833 tooltip = "EVTTOOLTIPLoR.833" }
			}
			add_trait = eunuch
			opinion = {
				modifier = opinion_castrated_me
				who = FROM
			}
			FROM = {
				if = {
					limit = { NOT = { trait = cruel } }
					custom_tooltip = {
						text = cruel_imprisoner_trait_chance_TT
						random = {
							chance = 25
							add_trait = cruel
							hidden_tooltip = {
								character_event = { id = 38259 }
							}
						}
					}
				}
				piety = -50
			}
			hidden_tooltip = {
				mother = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				father = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				spouse = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				any_child = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				if = {
					limit = {
						FROM = {
							NOT = { dynasty = ROOT }
							NOT = { sibling = ROOT }
						}
					}
					any_sibling = {
						opinion = {
							modifier = opinion_castrated_close_kin
							who = FROM
						}
					}
					any_dynasty_member = {
						opinion = {
							modifier = opinion_castrated_family
							who = FROM
						}
					}
				}
				FROM = {
					remove_opinion = { who = ROOT modifier = opinion_traitor }
					remove_opinion = { who = ROOT modifier = opinion_rebel_traitor }
					remove_opinion = { who = ROOT modifier = opinion_dishonorable }
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				OR = {
					reverse_opinion = { who = FROM value = 40 }
					FROM = { NOT = { piety = 100 } }
					FROM = { LIEGE = { dynasty = ROOT } }
				}
			}
			modifier = {
				factor = 0
				FROM = { trait = kind }
			}
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 1.2
				FROM = {
					OR = {
						trait = cruel
						trait = impaler
					}
				}
			}
		}
	}
	
##################################
####### Blinding Decision ########
##################################
	
	blinding_action = {
		only_playable = yes
		filter = court
		ai_target_filter = court
		ai_check_interval = 12
	
		from_potential = {
			has_dlc = "Legacy of Rome"
			is_playable = yes
			trait = cruel
			NOT = {
				culture_group = byzantine
				any_owned_bloodline = {
					has_bloodline_flag = bloodline_blinding
				}
			}
		}
	
		potential = {
			host = { character = FROM }
			prisoner = yes
			NOT = { trait = blinded }
		}
		
		allow = {
			prisoner = yes
		}
		
		effect = {
			hidden_tooltip = {
				FROM = {
					character_event = { id = LoR.830 }
				}
				character_event = { id = LoR.831 tooltip = "EVTTOOLTIPLoR.831" }
			}
			if = {
				limit = {
					trait = one_eyed
				}
				remove_trait = one_eyed
			}
			add_trait = blinded
			opinion = {
				modifier = opinion_blinded_me
				who = FROM
			}
			FROM = {
				if = {
					limit = { NOT = { trait = cruel } }
					custom_tooltip = {
						text = cruel_imprisoner_trait_chance_TT
						random = {
							chance = 25
							add_trait = cruel
							hidden_tooltip = {
								character_event = { id = 38259 }
							}
						}
					}
				}
				piety = -50
			}
			hidden_tooltip = {
				mother = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				father = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				spouse = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				any_child = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				if = {
					limit = {
						FROM = {
							NOT = { dynasty = ROOT }
							NOT = { sibling = ROOT }
						}
					}
					any_sibling = {
						opinion = {
							modifier = opinion_blinded_close_kin
							who = FROM
						}
					}
					any_dynasty_member = {
						opinion = {
							modifier = opinion_blinded_family
							who = FROM
						}
					}
				}
				FROM = {
					remove_opinion = { who = ROOT modifier = opinion_traitor }
					remove_opinion = { who = ROOT modifier = opinion_rebel_traitor }
					remove_opinion = { who = ROOT modifier = opinion_dishonorable }
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				OR = {
					reverse_opinion = { who = FROM value = 40 }
					FROM = { NOT = { piety = 100 } }
					FROM = { LIEGE = { dynasty = ROOT } }
				}
			}
			modifier = {
				factor = 0
				FROM = { trait = kind }
			}
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 2
				is_pretender = yes
				FROM = {
					OR = {
						is_pretender = yes
						is_primary_heir = yes
					}
				}
			}
		}
	}

##############################
####### Send Courtier ########
##############################

	send_courtier = {
		filter = all
		diplomacy_icon = GFX_send_courtier_icon
		
		third_party_filter = all
        third_party = FROM
		
        third_party_potential = {
            FROMFROM = {
                prisoner = no
				is_ruler = no
				host = { character = FROMFROM }
				NOT = { has_character_modifier = mark_courtier_tag }
			}
        }
		
		from_potential = {
		    prisoner = no
			is_ruler = yes
			ai = no
		}
		
		potential = {
		    prisoner = no
			is_ruler = yes
		}
		
		allow = {
            always = yes
    	}
		
        effect = {
		    FROMFROM = {
				add_character_modifier  = {
					name = mark_courtier_tag
					duration = 360
				}
			}
			ROOT = {	
				character_event = { id = court.01 days = 1 }
			}
		}
    }
	
#########################
####### Ancestor ########
#########################
	
	become_ancestor = {
		filter = self

		potential = {
			ai = no
			NOT = {
			    any_owned_bloodline = {
				    has_bloodline_flag = ancestor_bloodline_flag
			    }
		    }
		}

		allow = {
			always = yes
		}
		
		effect = {
		    create_bloodline = {
                type = ancestor_bloodline
            }
        }
	}
	
##############################
####### Mariage forcé ########
##############################

	PM_forced_marriage = {
		ai_check_interval = 12
		filter = court
		ai_target_filter = none
		third_party_filter = home_court_including_me
		ai_third_party_filter = home_court
		third_party = FROM

		from_potential = {
			ai = no
			is_playable = yes
			is_adult = yes
			prisoner = no
		}

		potential = {
			prisoner = yes
			host = { character = FROM }
			NOT = {	any_spouse = { character = FROM } }
		}

		allow = {
			show_only_failed_conditions = yes
			is_marriage_adult = yes
			is_ruler = no
		}

		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no
				is_adult = yes
				prisoner = no
				OR = {
					is_ruler = no
					ai = no
				}
				NOR = { 
					trait = incapable
					trait = eunuch
					same_sex = ROOT
					any_spouse = { character = ROOT }
				}
				OR = {
					AND = {
						is_betrothed = no
						is_married = no
					}
					AND = {
						is_betrothed = no
						has_polygamy = yes
						is_female = no
						NOT =  { any_spouse = { count = 4 } }
					}
					AND = {
						has_polygamy = yes
						is_female = no
						NOT =  { any_spouse = { count = 3 } }
					}
				}
			}
		}

		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				custom_tooltip = {
					text = PM_can_marry
					OR = {
						can_marry = yes
						AND = {
							can_marry = no
							OR = {
								is_married = yes
								is_betrothed = yes
							}
							has_polygamy = yes
							is_female = no
							OR = {
								AND = {
									is_betrothed = no
									NOT =  { any_spouse = { count = 4 } }
								}
								AND = {
									is_betrothed = yes
									NOT =  { any_spouse = { count = 3 } }
								}
							}
						}
					}
				}
				custom_tooltip = {
					text = PM_incest_religion
					OR = {
						NOR = {
							is_parent_of = prev
							is_child_of = prev
							sibling = prev
						}
						religion = zoroastrian
						religion = messalian
						has_religion_feature = religion_holy_family
						has_religion_feature = religion_feature_zun
						religion = egyptian_pagan
						religion = aten_pagan
						religion = winter_religion
						AND = {
							religion = valyrian_rel
							sibling = prev
						}
					}
				}
			}
		}

		effect = {
			hidden_tooltip = {
				spouse = {
					opinion = {
						modifier = opinion_forced_wife_consort
						who = FROM
					}
					opinion = {
						modifier = opinion_forced_wife_consort
						who = FROMFROM
					}
					remove_spouse = ROOT
				}
				any_close_relative = {
					opinion = {
						modifier = opinion_forced_relative_consort
						who = FROM
					}
					opinion = {
						modifier = opinion_forced_relative_consort
						who = FROMFROM
					}
				}
				opinion = {
					modifier = opinion_forced_consort
					who = FROM
				}
				opinion = {
					modifier = opinion_forced_consort
					who = FROMFROM
				}
			}
			if = {
				limit = { is_female = yes }
				add_spouse = FROMFROM
			}
			else = {
				add_spouse_matrilineal = FROMFROM
			}
			imprison = no
			custom_tooltip = { text = PM_angry_family }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
			}
		}
	}

	PM_forced_marriage_AI = {
		ai_check_interval = 12
		filter = court
		ai_target_filter = court

		from_potential = {
			ai = yes
			is_playable = yes
			is_adult = yes
			prisoner = no
			NOR = { 
				trait = incapable
				trait = eunuch
			}
			OR = {
				is_married = no
				AND = {
					has_polygamy = yes
					NOT =  { any_spouse = { count = 4 } }
				}
			}
		}
		potential = {
			prisoner = yes
			host = { character = FROM }
			NOT = { same_sex = FROM }
		}
		allow = {
			is_marriage_adult = yes
			is_ruler = no
			FROM = {
				NOT = {
					trait = celibate
				}
				OR = {
					NOR = {
						is_parent_of = prev
						is_child_of = prev
						sibling = prev
					}
					religion = zoroastrian
					religion = messalian
					has_religion_feature = religion_holy_family
				}
			}
		}
		effect = {
			hidden_tooltip = {
				spouse = {
					opinion = {
						modifier = opinion_forced_wife_consort
						who = FROM
					}
					remove_spouse = ROOT
				}
				any_close_relative = {
					opinion = {
						modifier = opinion_forced_relative_consort
						who = FROM
					}
				}
				opinion = {
					modifier = opinion_forced_consort
					who = FROM
				}
			}
			if = {
				limit = { is_female = yes }
				add_spouse = FROM
			}
			else = {
				add_spouse_matrilineal = FROM
			}
			imprison = no
			custom_tooltip = { text = PM_angry_family }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.01
			}
			modifier = {
				factor = 0
				FROM = {
					NOR = {	
						trait = kind
						trait = just
						trait = chaste
						trait = celibate
					}
				}
			}
			modifier = {
				factor = 0
				ROOT = {
					OR = {	
						trait = ugly
						trait = hunchback
						trait = celibate
						trait = eunuch
						AND = {
							is_female = yes
							age = 40
						}
						dynasty = none
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					is_close_relative = ROOT
					NOR = {	
						religion = zoroastrian
						religion = messalian
						has_religion_feature = religion_holy_family
						trait = arbitrary
						trait = possessed
						trait = lunatic
					}
				}
			}
			modifier = {
				factor = 10
				FROM = {
					is_close_relative = ROOT
					OR = {	
						religion = zoroastrian
						religion = messalian
						has_religion_feature = religion_holy_family
					}
				}
			}
			modifier = {
				factor = 10
				FROM = {
					OR = {	
						trait = arbitrary
						trait = possessed
						trait = lunatic
					}
				}
			}
			modifier = {
				factor = 10
				ROOT = {
					any_parent = {
						tier = higher_than_baron
					}
				}
			}
			modifier = {
				factor = 10
				ROOT = {
					any_parent = {
						tier = higher_than_duke
					}
				}
			}
			modifier = {
				factor = 0.1
				FROM = {
					OR = {
						tier = higher_than_baron
						any_parent = { tier = higher_than_baron }
					}
				}
			}
			modifier = {
				factor = 0.1
				FROM = {
					OR = {
						tier = higher_than_duke
						any_parent = { tier = higher_than_duke }
					}
				}
			}
			modifier = {
				factor = 10
				NOT = { age = 26 }
			}
			modifier = {
				factor = 0.1
				age = 36
			}
			modifier = {
				factor = 0.1
				age = 46
			}
			modifier = {
				factor = 10
				FROM = {
					OR = {	
						is_tribal = yes
						is_nomadic = yes
					}
				}
			}
			modifier = {
				factor = 10
				FROM = {
					OR = {	
						trait = lustful
						trait = hedonist
					}
					OR = {	
						trait = homosexual
						NOT = { same_sex = ROOT }
					}
				}
				ROOT = {
					is_attractive_trigger = yes
					NOT = { age = 40 }
				}
			}
			modifier = {
				factor = 10
				ROOT = {
					NOR = {
						trait = inbred
						trait = imbecile
					}
					OR = {	
						trait = genius
						trait = quick
					}
				}
			}
			modifier = {
				factor = 10
				ROOT = {
					NOR = {
						trait = inbred
						trait = imbecile
					}
					OR = {
						trait = strong
						trait = fair
					}
				}
			}
			modifier = {
				factor = 100
				ROOT = {
					trait = horse
				}
				FROM = {
					trait = lunatic
				}
			}
		}
	}
	
########################################
####### Transférer le vasselage ########
########################################
	
	send_vassal = {
		filter = all
		diplomacy_icon = GFX_send_vassal_icon
		
		third_party_filter = all
        third_party = FROM
		
        third_party_potential = {
            FROMFROM = {
			    is_liege_or_above = FROMFROM
				lower_tier_than = ROOT
				is_ruler = yes
			}
        }
		
		from_potential = {
		    prisoner = no
			is_ruler = yes
		}
		
		potential = {
		    prisoner = no
			is_ruler = yes
			#liege = { NOT = { character = FROM } }
		}
		
		allow = {
            always = yes
    	}
		
        effect = {
		    FROMFROM = { set_defacto_liege = ROOT }
		}
		
		ai_will_do = {
			factor = 0
		}
    }
	
	transfer_desired = {
        filter = sub_realm
        ai_target_filter = sub_realm

        from_potential = {
            in_revolt = no
            higher_tier_than = COUNT
            ai = no
        }

        potential = {
            is_ruler = yes
            is_liege_or_above = FROM
            FROM = {
                any_vassal = {
                    cvt_can_be_transferred_trigger = yes
                    primary_title = {
                        dejure_liege_title = {
                            holder_scope = {
                                character = ROOT
                            }
                        }
                    }
                }
            }
        }

        effect = {
            FROM = {
                any_vassal = {
                    limit = {
                        cvt_can_be_transferred_trigger = yes
                        primary_title = {
                            dejure_liege_title = {
                                holder_scope = {
                                    character = ROOT
                                }
                            }
                        }
                    }
                    set_defacto_liege = ROOT
                    recalc_succession = yes
                    ROOT = {
                        opinion = { modifier = opinion_vassal_transfer  who = FROM  months = 120 }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 0
        }

    }
	
	transfer_baron_to_count = {
        filter = vassals
        ai_target_filter = vassals
		ai_check_interval = 6

        from_potential = {
            in_revolt = no
            higher_tier_than = COUNT
        }

        potential = {
            tier = BARON
            liege = { character = FROM }
            primary_title = {
                dejure_liege_title = {
                    holder_scope = {
                        is_liege_or_above = FROM
                    }
                }
            }
        }

        allow = {
            cvt_can_be_transferred_trigger = yes
        }

        effect = {
            primary_title = {
                dejure_liege_title = {
                    holder_scope = {
                        ROOT = {
                            set_defacto_liege = PREV
                            recalc_succession = yes
                        }
                        opinion = { modifier = opinion_vassal_transfer  who = FROM  months = 120 }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 1
        }

    }
	
	transfer_count_to_duke = {
        filter = vassals
        ai_target_filter = vassals
		ai_check_interval = 24

        from_potential = {
            in_revolt = no
            higher_tier_than = DUKE
        }

        potential = {
            tier = COUNT
            liege = { character = FROM }
            primary_title = {
                dejure_liege_title = {
                    holder_scope = {
                        is_liege_or_above = FROM
                    }
                }
            }
        }

        allow = {
            cvt_can_be_transferred_trigger = yes
        }

        effect = {
            primary_title = {
                dejure_liege_title = {
                    holder_scope = {
                        ROOT = {
                            set_defacto_liege = PREV
                            recalc_succession = yes
                        }
                        opinion = { modifier = opinion_vassal_transfer  who = FROM  months = 120 }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 1
			modifier = {
				factor = 0.01
			}
            modifier = {
                factor = 10
                OR = { in_faction = yes  leads_faction = yes }
            }

            modifier = {
                factor = 50
                FROM = { over_vassal_limit = 1 }
            }
        }

    }
	
	transfer_count_to_king = {
        filter = vassals
        ai_target_filter = vassals
		ai_check_interval = 24

        from_potential = {
            in_revolt = no
            higher_tier_than = KING
        }

        potential = {
            tier = COUNT
            liege = { character = FROM }
            primary_title = {
                dejure_liege_title = {
                    dejure_liege_title = {
                        holder_scope = {
                            is_liege_or_above = FROM
                        }
                    }
                }
            }
        }

        allow = {
            cvt_can_be_transferred_trigger = yes
        }

        effect = {
            primary_title = {
                dejure_liege_title = {
                    dejure_liege_title = {
                        holder_scope = {
                            ROOT = {
                                set_defacto_liege = PREV
                                recalc_succession = yes
                            }
                            opinion = { modifier = opinion_vassal_transfer  who = FROM  months = 120 }
                        }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 1
			modifier = {
				factor = 0.01
			}
            modifier = {
                factor = 10
                OR = { in_faction = yes  leads_faction = yes }
            }

            modifier = {
                factor = 50
                FROM = { over_vassal_limit = 1 }
            }
        }

    }
	
	transfer_duke_to_king = {
        filter = vassals
        ai_target_filter = vassals
		ai_check_interval = 24

        from_potential = {
            in_revolt = no
            higher_tier_than = KING
        }

        potential = {
            tier = DUKE
            liege = { character = FROM }
            primary_title = {
                dejure_liege_title = {
                    holder_scope = {
                        is_liege_or_above = FROM
                    }
                }
            }
        }

        allow = {
            cvt_can_be_transferred_trigger = yes
        }

        effect = {
            primary_title = {
                dejure_liege_title = {
                    holder_scope = {
                        ROOT = {
                            set_defacto_liege = PREV
                            recalc_succession = yes
                        }
                        opinion = { modifier = opinion_vassal_transfer  who = FROM  months = 120 }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 1
			modifier = {
				factor = 0.01
			}
            modifier = {
                factor = 10
                OR = { in_faction = yes  leads_faction = yes }
            }

            modifier = {
                factor = 50
                FROM = { over_vassal_limit = 1 }
            }
        }

    }
	
	transfer_titular_duke_to_king = {
        filter = vassals
        ai_target_filter = vassals
		ai_check_interval = 24

        from_potential = {
            in_revolt = no
            higher_tier_than = KING
            OR = {
                ai = no
                over_vassal_limit = 1
            }
        }

        potential = {
            tier = DUKE
            liege = { character = FROM }
            primary_title = {
                is_titular = yes
                temporary = no
            }
        }

        allow = {
            is_landed = yes
            capital_scope = {
                kingdom = {
                    holder_scope = {
                        is_liege_or_above = FROM
                    }
                }
            }
            cvt_can_be_transferred_trigger = yes
        }

        effect = {
            capital_scope = {
                kingdom = {
                    holder_scope = {
                        ROOT = {
                            set_defacto_liege = PREV
                            recalc_succession = yes
                        }
                        opinion = { modifier = opinion_vassal_transfer  who = FROM  months = 120 }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 1
			modifier = {
				factor = 0.2
			}
            modifier = {
                factor = 2
                OR = { in_faction = yes  leads_faction = yes }
            }

            modifier = {
                factor = 0
                OR = {
                    holy_order = yes
                    mercenary = yes
                    rightful_religious_head_scope = { character = PREV }
                }
            }
        }

    }
	
	transfer_count_to_neighbor = {
        filter = vassals
        third_party_filter = sub_realm
        ai_third_party_filter = vassals
        show_third_party_potential = yes
        only_playable = yes

        from_potential = {
            in_revolt = no
            or = {
                ai = no
                over_vassal_limit = 1
            }
        }

        potential = {
            liege = { character = FROM }
        }

        allow = {
            cvt_can_be_transferred_trigger = yes
        }

        third_party_potential = {
            FROMFROM = {
                show_scope_change = no
                is_liege_or_above = ROOT_FROM  # Needed to prevent transfer to vassals rebelling against me (who somehow meet 'filter = sub_realm')
                #higher_tier_than = COUNT
				higher_tier_than = ROOT
                shares_realm_border_with = ROOT
                num_of_count_titles_in_realm = 1  # Don't transfer counts under a religious head who has only a bishopric, for example
                #cvt_no_temporary_title_trigger = yes
            }
        }

        effect = {
            log = "CVT: [From.GetTitledName] transferred [Root.GetTitledName] under [Root.GetHerHis] neighbor, [FromFrom.GetTitledName]"
            set_defacto_liege = FROMFROM
            recalc_succession = yes
            FROMFROM = { show_scope_change = no  opinion = { modifier = opinion_vassal_transfer  who = ROOT_FROM  months = 120 } }
        }

        ai_will_do = {
            factor = 0
        }
    }
	
#################################
####### Offrir une Faveur #######
#################################
	
	offer_favor = {
		filter = all
		diplomacy_icon = GFX_favor_improve_icon_1
		
		from_potential = {
		    ai = no
			is_incapable = no
			prisoner = no
			NOT = { has_character_flag = offer_favor_flag }
		}
		
		potential = {
			is_incapable = no
		}
		
		allow = {
			FROM = { NOT = { owes_favor_to = ROOT } }
    	}
		
        effect = {
		    FROM = { set_character_flag = offer_favor_flag }
		    ROOT = { character_event = { id = favor.1 days = 1 } }
		}
		
		ai_will_do = {
			factor = 0
		}
    }
	
#################################
####### Vendre une Faveur #######
#################################

	sell_favor = {
		filter = all
		diplomacy_icon = GFX_favor_improve_icon_1
		
		from_potential = {
			ai = no
			OR = {
				is_landed = no
				is_republic = yes
				primary_title = { has_title_flag = adventurer_title }
			}
			is_incapable = no
			prisoner = no
			NOT = { has_character_flag = sell_favor_flag }
		}
		
		potential = {
            owes_favor_to = FROM
			is_incapable = no
			is_landed = yes
			NOT = { has_character_modifier = dishonored_favor }
		}
		
		allow = {
			always = yes
		}
		
		effect = {
		    FROM = { set_character_flag = sell_favor_flag }
			ROOT = { character_event = { id = favor.4 days = 1 } }
		}
	
		ai_will_do = {
			factor = 0
		}
	}
	
################################################
####### Offrir de se joindre à la guerre #######
################################################

	war_favor = {
		filter = all
		ai_target_filter = liege
		ai_check_interval = 24
		diplomacy_icon = GFX_favor_improve_icon_1
		
		from_potential = {
			war = no
			higher_tier_than = BARON
			is_incapable = no
			prisoner = no
			NOT = { has_character_flag = war_favor_flag }
		}
		
		potential = {
		    same_realm = FROM
			war = yes
			OR = {
			    is_primary_war_attacker = yes
				is_primary_war_defender = yes
			}
			is_incapable = no
			NOT = { reverse_has_opinion_modifier = { who = FROM modifier = favor_timer_1 } }
		}
		
		allow = {
			ROOT = { NOT = { owes_favor_to = FROM } }
		}
		
		effect = {
		    FROM = { set_character_flag = war_favor_flag }
			ROOT = { character_event = { id = favor.7 days = 1 } }
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				ROOT = { ai = no }
			}
			modifier = {
				factor = 0
				NOT = {
					reverse_opinion = {
						who = FROM
						value = 50
					}
				}
			}
		}
	}
	
#############################################
####### Inviter à rejoindre ma guerre #######
#############################################

	ask_war_favor = {
		filter = vassals
		ai_target_filter = vassals
		ai_check_interval = 12
		diplomacy_icon = GFX_favor_improve_icon_1
		
		from_potential = {
			war = yes
			OR = {
			    is_primary_war_attacker = yes
				is_primary_war_defender = yes
			}
			is_incapable = no
			prisoner = no
			NOT = { has_character_flag = ask_war_favor_flag }
		}
		
		potential = {
		    war = no
			FROM = { is_liege_of = ROOT }
			higher_tier_than = BARON
			is_incapable = no
			NOT = { has_character_modifier = dishonored_favor }
			NOT = { reverse_has_opinion_modifier = { who = FROM modifier = favor_timer_2 } }
		}
		
		allow = {
			FROM = { NOT = { owes_favor_to = ROOT } }
		}
		
		effect = {
		    FROM = { set_character_flag = ask_war_favor_flag }
			ROOT = { character_event = { id = favor.10 days = 1 } }
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				FROM = { NOT = { holds_favor_on = ROOT } }
			}
			modifier = {
				factor = 2
				FROM = {
					any_war = {
						defender = { character = PREV }
						attacker = {
							war_score = 25
						}
					}
				}
			}
		}
	}
	
#################################
####### Empire Dynastique #######
#################################
	
	empire_dynasty = {
		filter = dynasty
		ai_target_filter = dynasty
		ai_check_interval = 48
		diplomacy_icon = GFX_empire_dynastique_icon
		
		from_potential = {
		    ai = no
			is_ruler = yes
			NOT = { has_character_flag = ask_empire_dynasty_flag }
			OR = {
			    tier = DUKE
				tier = KING
			}
			independent = yes
			NOT = { has_landed_title = k_papal_state }
		}
		
		potential = {
		    dynasty = FROM
			is_ruler = yes
			OR = {
			    tier = DUKE
				tier = KING
			}
			independent = yes
			NOT = { has_landed_title = k_papal_state }
		}
		
		allow = {
		    custom_tooltip = { text = ASK_UNIONDYN ROOT = { NOT = { reverse_has_opinion_modifier = { who = FROM modifier = opinion_ask_uniondyn } } } }
		    OR = {
			    AND = {
                    FROM = {
					    tier = KING
					    realm_size = 70
					}
			        ROOT = {
					    tier = KING
					    realm_size = 60
					}
			    }
				AND = {
                    FROM = {
					    tier = DUKE
					    realm_size = 40
					}
			        ROOT = {
					    tier = DUKE
					    realm_size = 30
					}
			    }
			}
    	}
		
        effect = {
			FROM = {
			    set_character_flag = ask_empire_dynasty_flag
			    character_event = { id = empsty.1 }
			}
		}
		
		ai_will_do = {
			factor = 0
		}
		
    }
	
########################
####### Cardinal #######
########################

	make_cardinal = {
		filter = all
		diplomacy_icon = GFX_make_cardinal_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
		}
		
		potential = {
			is_theocracy = yes
			religion = FROM
			NOT = { has_minor_title = title_cardinal }
		}
		
		allow = {
		    NOT = { trait = excommunicated }
			custom_tooltip = {
				text = cardinaux_max
				NOT = {
					OR = {
						has_minor_title = title_cardinal
						has_assigned_minor_title = {
							title = title_cardinal count = 9
						}
					}
				}
			}
		}
		
		effect = {
			hidden_tooltip = {
			    save_event_target_as = cardinal_target
				create_character = {
					random_traits = no
					culture = ROOT
					religion = ROOT
					age = 16
					employer = FROM
					attributes = {
						martial = 6
						intrigue = 6
						diplomacy = 6
						stewardship = 6
						learning = 6				
					}
				}
				new_character = {
					save_event_target_as = cardinal_temp
				}
				abdicate_to = event_target:cardinal_temp
				move_character = FROM
				set_government_type = theocracy_government
				character_event = { id = cathimprov.23 }
			}
		}
	}
	
###########################
####### Investiture #######
###########################
	
	ask_investiture_law = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			religion_authority = 0.35
			NOT = { has_character_flag = pope_currently_demanding }
			is_incapable = no
			prisoner = no
			war = no
			ai = no
		}
		
		potential = {
			NOT = {	has_character_flag = pope_wants_our_law_changed }
			NOT = {	has_character_flag = pope_respects_our_law }
			primary_title = {
				OR = {
					tier = KING
					tier = EMPEROR
				}
				has_law = investiture_law_1
			}
		}
		
		allow = {
			year = 1000
			ROOT = {
				religion = FROM
				rightful_religious_head = FROM
				primary_title = {
					OR = {
						tier = KING
						tier = EMPEROR
					}
					has_law = investiture_law_1 
				}
			}
		}
		
		effect = {
			ROOT = {
				character_event = { id = cathimprov.25 days = 1 tooltip = EVTTOOLTIP67001 }
				set_character_flag = pope_wants_our_law_changed
			}
			FROM = { set_character_flag = pope_currently_demanding }
		}
	}
	
	claim_investiture_law = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			has_character_flag = pope_currently_demanding
			prisoner = no
			is_incapable = no
			war = no
			ai = no
		}
		
		potential = {
			liege = {
				has_character_flag = pope_we_refuse_law_changed
				primary_title = {
					OR = { tier = KING tier = EMPEROR }
					has_law = investiture_law_1 
				}
			}
			NOT = { has_character_flag = pope_vassal_approached }
		}
		
		allow = {
			year = 1000
			ROOT = {
				liege = {
					religion = FROM
					rightful_religious_head = FROM
					primary_title = {
						OR = { tier = KING tier = EMPEROR }
						has_law = investiture_law_1 
					}
				}
				religion = FROM
			}
		}
		
		effect = {
			ROOT = {
				set_character_flag = pope_vassal_approached 
				character_event = { id = cathimprov.32 days = 1 tooltip = EVTTOOLTIP67021 }
			}
			FROM = { clr_character_flag = pope_currently_demanding }
		}
	}
	
################################
####### Aide à la guerre #######
################################
	
	send_war_aid = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			is_incapable = no
			prisoner = no
			war = no
			ai = no
		}
		
		potential = {
			is_ruler = yes
		}
		
		allow = {
			FROM = { wealth = 500 }
			ROOT = {
				religion = FROM
				NOT = { wealth = 1000 }
				religion_head = {
					character = FROM
				}
				any_current_enemy = {
					NOT = { religion_group = PREV }
				}
				NOT = { war_with = FROM }
			}
		}
		
		effect = {
			wealth = -500
			ROOT = { letter_event = { id = cathimprov.28 days = 1 tooltip = EVTTOOLTIP39201 } }
		}
	}
	
###########################################
####### Participation à la croisade #######
###########################################
	
	send_crusade_participation = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			is_incapable = no
			prisoner = no
			war = no
			ai = no
		}
		
		potential = {
			NOT = {
				any_war = {
					OR = {
						using_cb = crusade
						using_cb = new_crusade
					}
				}
			}
			NOT = { mercenary = yes }
			is_ruler = yes
		}
		
		allow = {
			is_preparing_crusade = yes
			ROOT = {
				religion = catholic
				NOT = {
					has_pledged_crusade_participation = yes
				}
				rightful_religious_head_scope = {
					character = FROM
				}
				NOT = {
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_not_participating_in_crusade_emperor
					}
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_not_participating_in_crusade_king
					}
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_not_participating_in_crusade_duke
					}
					reverse_has_opinion_modifier = {
						who = FROM
						modifier = opinion_not_participating_in_crusade_count
					}
				}
			}
		}
		
		effect = {
			ROOT = { letter_event = { id = cathimprov.29 days = 1 } }
		}
	}
	
##########################
####### Indulgence #######
##########################

	send_absolution_parricide = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			is_incapable = no
			prisoner = no
			war = no
			ai = no
		}
		
		potential = {
			NOT = {
				primary_title = {
					OR = {
						tier = KING
						tier = EMPEROR
					}
					has_law = investiture_law_1
				}
			}
			religion = FROM
			rightful_religious_head = FROM
			NOT = { has_character_flag = kinslaying_offered }
		}
		
		allow = {
			is_any_kinslayer_trigger = yes
		}
		
		effect = {
			ROOT = { character_event = { id = cathimprov.35 days = 1 tooltip = EVTTOOLTIP39211 } }
		}
	}
	
##################################
####### Bénéficiaire papal #######
##################################
	
	papal_beneficiary = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			is_incapable = no
			prisoner = no
			ai = no
		}
		
		potential = {
			religion = FROM
			rightful_religious_head = FROM
		}
		
		allow = {
			religion = FROM	
			rightful_religious_head = FROM
			prisoner = no
			in_revolt = no
			OR = {
				has_pledged_crusade_participation = yes		
				is_landed = no
			}	
			catholic = { 
				OR = { 
					is_preparing_crusade = yes
					has_crusade_war_started = yes
				}
			}
			NOT = { official_crusade_recipient = { character = ROOT } }
			NOT = {
				mercenary = yes
				holy_order = yes
				is_theocracy = yes
				is_republic = yes
				has_minor_title = title_cardinal
			}
		}
		
		effect = {
			ROOT = { letter_event = { id = cathimprov.36 days = 1 } }
		}
	}
	
	remove_papal_beneficiary = {
		filter = all
		diplomacy_icon = GFX_ask_investiture_law_icon
		
		from_potential = {
			has_landed_title = k_papal_state
			OR = {
				religion = catholic
				religion = fraticelli
			}
			controls_religion = yes
			is_incapable = no
			prisoner = no
			war = no
			ai = no
		}
		
		potential = {
			official_crusade_recipient = { character = ROOT }
		}
		
		allow = {
			always = yes
		}
		
		effect = {
			crusade_target_title = {
				save_event_target_as = current_crusade_target_title
			}
			official_crusade_recipient = {
				save_event_target_as = old_crusade_recipient 
			}
			set_official_crusade_recipient  = NONE
			any_crusade_participant = { letter_event = { id = HFP.41121 days = 1 } }
		}
	}
	
############################
####### IA Assistant #######
############################

	keep_commander = {
		filter = all

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_commander_appointments
		   }
		}
		
		potential = {
			NOT = { has_character_flag = keep_commander_flag }
			has_minor_title = title_commander
			FROM = { is_liege_of = ROOT }
		}
		
		allow = {
		}
		
		effect = {
			ROOT = { set_character_flag = keep_commander_flag }
		}
	}
	
	not_keep_commander = {
		filter = all

		from_potential = {
			is_ruler = yes
			ai = no
		}
		
		potential = {
			has_character_flag = keep_commander_flag
			has_minor_title = title_commander
			FROM = { is_liege_of = ROOT }
		}
		
		allow = {
		}
		
		effect = {
			ROOT = { clr_character_flag = keep_commander_flag }
		}
	}
	
	not_educate_children = {
		filter = court

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			NOT = { has_character_flag = not_educate_children }
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = { set_character_flag = not_educate_children }
		}
	}
	
	can_educate_children = {
		filter = court

		from_potential = {
			is_ruler = yes
			ai = no	    
		}
		
		potential = {
			has_character_flag = not_educate_children
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = {
				clr_character_flag = not_educate_children
				clr_character_flag = diplomacy_education
				clr_character_flag = martial_education
				clr_character_flag = stewardship_education
				clr_character_flag = intrigue_education
				clr_character_flag = learning_education
			}
		}
	}
	
	diplomacy_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_diplomacy

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			NOT = { has_character_flag = not_educate_children }
			NOT = { has_character_flag = diplomacy_education }
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = {
				set_character_flag = diplomacy_education
				clr_character_flag = martial_education
				clr_character_flag = stewardship_education
				clr_character_flag = intrigue_education
				clr_character_flag = learning_education
			}
			remove_guardian = ROOT
		}
	}
	
	not_diplomacy_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_diplomacy

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			has_character_flag = diplomacy_education
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = { clr_character_flag = diplomacy_education }
			remove_guardian = ROOT
		}
	}
	
	martial_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_martial

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			NOT = { has_character_flag = not_educate_children }
			NOT = { has_character_flag = martial_education }
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = {
				clr_character_flag = diplomacy_education
				set_character_flag = martial_education
				clr_character_flag = stewardship_education
				clr_character_flag = intrigue_education
				clr_character_flag = learning_education
			}
			remove_guardian = ROOT
		}
	}
	
	not_martial_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_martial

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			has_character_flag = martial_education
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = { clr_character_flag = martial_education }
			remove_guardian = ROOT
		}
	}
	
	stewardship_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_stewardship

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			NOT = { has_character_flag = not_educate_children }
			NOT = { has_character_flag = stewardship_education }
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = {
				clr_character_flag = diplomacy_education
				clr_character_flag = martial_education
				set_character_flag = stewardship_education
				clr_character_flag = intrigue_education
				clr_character_flag = learning_education
			}
			remove_guardian = ROOT
		}
	}
	
	not_stewardship_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_stewardship

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			has_character_flag = stewardship_education
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = { clr_character_flag = stewardship_education }
			remove_guardian = ROOT
		}
	}
	
	intrigue_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_intrigue

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			NOT = { has_character_flag = not_educate_children }
			NOT = { has_character_flag = intrigue_education }
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = {
				clr_character_flag = diplomacy_education
				clr_character_flag = martial_education
				clr_character_flag = stewardship_education
				set_character_flag = intrigue_education
				clr_character_flag = learning_education
			}
			remove_guardian = ROOT
		}
	}
	
	not_intrigue_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_intrigue

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			has_character_flag = intrigue_education
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = { clr_character_flag = intrigue_education }
			remove_guardian = ROOT
		}
	}
	
	learning_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_learning

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			NOT = { has_character_flag = not_educate_children }
			NOT = { has_character_flag = learning_education }
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = {
				clr_character_flag = diplomacy_education
				clr_character_flag = martial_education
				clr_character_flag = stewardship_education
				clr_character_flag = intrigue_education
				set_character_flag = learning_education
			}
			remove_guardian = ROOT
		}
	}
	
	not_learning_education_decision = {
		filter = court
		diplomacy_icon = GFX_icon_learning

		from_potential = {
			is_ruler = yes
			ai = no
			primary_title = {
			    has_title_flag = court_ai_enabled
			    has_title_flag = court_ai_kids_education
		   }
		}
		
		potential = {
			has_character_flag = learning_education
			NOT = { age = 16 }
		}
		allow = {
		}
		effect = {
			ROOT = { clr_character_flag = learning_education }
			remove_guardian = ROOT
		}
	}
	
########################
####### Dynastie #######
########################
	
	switch_dynasty = {
		filter = all
		diplomacy_icon = GFX_empire_dynastique_icon
		
		from_potential = {
		    ai = no
			NOT = { has_character_flag = ask_switch_dynasty_diplomatic_interview_flag }
		}
		
		potential = {
		    ai = no
			diplomatic_interview_trigger = yes
		}
		
		allow = {
		    always = yes
    	}
		
        effect = {
			custom_tooltip = {
				text = switch_dynasty_custom_tooltip
				hidden_tooltip = {
					ROOT = { letter_event = { id = RIPMOD.1 days = 1 } }
				}
			}
		    FROM = { set_character_flag = ask_switch_dynasty_diplomatic_interview_flag }
		}
    }
	
##########################
####### Republique #######
##########################

	holding_republic_decision = {
	    filter = self
		diplomacy_icon = GFX_rp_mod_ADI_11_icon
		
		potential = {
			ai = no
			is_republic = yes
			is_landed = no
			prisoner = no
		}
	
		allow = {
			FROM = {
				wealth = 400
			}
		    location = {
				is_capital = yes
				has_empty_holding = yes
			}
		}
		
		effect = {
			wealth = -400
			location = {
				build_holding = {
					type = city
					holder = FROM
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
##########################
####### Mercenaire #######
##########################

	mercenary_gold = {
	    filter = all
		diplomacy_icon = GFX_mercenary_gold_icon
		
		from_potential = {
			is_playable = yes
			OR = {
				AND = {
					is_landed = no
					is_republic = no
				}
				is_republic = yes
			}
		}
		potential = {
			mercenary = yes
			primary_title = {
				band_creator = {
					character = FROM
				}
			}
		}
		allow = {
			ROOT = { wealth > 50 }
		}
		effect = {
			if = {
				limit = {
					wealth >= 50
					wealth < 100
				}
				ROOT = { wealth = -50 }
				FROM = { wealth = 50 }
			}
			if = {
				limit = {
					wealth >= 100
					wealth < 200
				}
				ROOT = { wealth = -100 }
				FROM = { wealth = 100 }
			}
			if = {
				limit = {
					wealth >= 200
					wealth < 300
				}
				ROOT = { wealth = -200 }
				FROM = { wealth = 200 }
			}
			if = {
				limit = {
					wealth >= 300
					wealth < 400
				}
				ROOT = { wealth = -300 }
				FROM = { wealth = 300 }
			}
			if = {
				limit = {
					wealth >= 400
					wealth < 500
				}
				ROOT = { wealth = -400 }
				FROM = { wealth = 400 }
			}
			if = {
				limit = {
					wealth >= 500
					wealth < 1000
				}
				ROOT = { wealth = -500 }
				FROM = { wealth = 500 }
			}
			if = {
				limit = {
					wealth >= 1000
				}
				ROOT = { wealth = -1000 }
				FROM = { wealth = 1000 }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
			
		}
	}
	
######################
####### Pardon #######
######################
	
	give_pardon = {
		only_playable = yes
		filter = all
		#ai_target_filter = all
		#ai_check_interval = 12
		
		from_potential = {
			has_dlc = "Zeus"
			is_playable = yes
			NOT = { trait = incapable }
		}
		potential = {
		}
		allow = {
			FROM = {
				OR = {
					has_opinion_modifier = { who = ROOT modifier = declared_war }
					has_opinion_modifier = { who = ROOT modifier = opinion_dishonorable }
					has_opinion_modifier = { who = ROOT modifier = opinion_traitor }
					has_opinion_modifier = { who = ROOT modifier = opinion_rebel_traitor }
					has_opinion_modifier = { who = ROOT modifier = opinion_regicide_traitor }
					has_opinion_modifier = { who = ROOT modifier = opinion_killed_close_kin }
					has_opinion_modifier = { who = ROOT modifier = opinion_refused_abdicate_title }
					has_opinion_modifier = { who = ROOT modifier = opinion_fatwa_target }
					has_opinion_modifier = { who = ROOT modifier = opinion_refused_order }
					has_opinion_modifier = { who = ROOT modifier = opinion_witch }
					has_opinion_modifier = { who = ROOT modifier = opinion_takfir }
					has_opinion_modifier = { who = ROOT modifier = opinion_unfaithful_wife }
					has_opinion_modifier = { who = ROOT modifier = opinion_cuckolded }
					has_opinion_modifier = { who = ROOT modifier = opinion_charge_heresiarch }
					has_opinion_modifier = { who = ROOT modifier = opinion_charge_infidel }
					has_opinion_modifier = { who = ROOT modifier = opinion_charge_deviant }
					has_opinion_modifier = { who = ROOT modifier = opinion_charge_illegitimate }
					has_opinion_modifier = { who = ROOT modifier = opinion_charge_traitor }
					has_opinion_modifier = { who = ROOT modifier = opinion_charge_slanderer }
					has_opinion_modifier = { who = ROOT modifier = abuse_of_office }
				}
			}
		}
		effect = {
			hidden_tooltip = {
				ROOT = { save_event_target_as = pardon_target }
				FROM = { save_event_target_as = liege_target }
				character_event = { id = ZE.8121 days = 1 }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}

####################
####### TEST #######
####################
	
	#test_decision_a = {
	#    filter = all
	#    ai_target_filter = none
	#	
	#	from_potential = {
	#		ai = no
	#	}
	#	
	#	potential = {
	#	}
	#	
	#	allow = {
	#	}
	#	
	#	effect = {
	#		FROM = {
	#			set_looter_hostility_days = {
	#				who = ROOT
	#				days = 360
	#			}
	#		}
	#	}
	#	
	#	ai_will_do = {
	#		factor = 0
	#	}
	#}
	
}