targeted_decisions = {
	abdicate_rule = {
		filter = self
		ai_target_filter = self
		ai_check_interval = 12
		only_rulers = yes
		
		potential = {
			is_ruler = yes
			has_regent = no
			controls_religion = no
			is_nomadic = no
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			NOT = {
				has_character_flag = considering_abdication
			}
			is_not_busy_trigger = yes
			current_heir = {
				religion = ROOT
				dynasty = ROOT
				culture = ROOT
				war = no
				is_adult = yes
				NOR = {
					trait = incapable
					trait = lunatic
					trait = possessed
				}
			}
			age = 50
			ruled_years = 10
			OR = {
				NOT = { health = 3.1 }
				trait = depressed
				trait = stressed
				trait = infirm
			}
		}
		
		allow = {
			war = no
			NOR = {
				trait = ambitious
				trait = proud
				trait = lunatic
				trait = possessed
				trait = paranoid
				trait = envious
				trait = greedy
			}
		}
		
		effect = {
			set_character_flag = considering_abdication
			character_event = { id = Plus.120 tooltip = consider_abdication }
		}
		
		ai_will_do = {
			factor = 1
			modifier = { 
				factor = 0 
				NOT = { age = 60 } 
			}
			modifier = { 
				factor = 0 
				NOT = { ruled_years = 15 }
			}
			modifier = {
				factor = 0
				NOT = {
					current_heir = {
						reverse_opinion = { who = ROOT value = 25 }
					}
				}
			}
			modifier = {
				factor = 0
				NOT = {
					trait = content
					trait = humble
				}
			}
		}
	}

	disinherit_child = {
		filter = dynasty
		ai_target_filter = dynasty
		ai_check_interval = 12
		only_playable = yes
		only_rulers = yes
		
		from_potential = {
			is_ruler = yes
			is_playable = yes
			has_regent = no
			is_nomadic = no
			NOT = { has_character_flag = disinherited_child }
		}
		potential = {
			is_child_of = FROM
			dynasty = FROM
			any_heir_title = {
				is_primary_holder_title = yes
				holder = FROM
			}
		}
		allow = {
			FROM = {
				war = no
				OR = {
					AND = {
						tier = COUNT
						prestige = 500
					}
					AND = {
						tier = DUKE
						prestige = 1000
					}
					AND = {
						tier = KING
						prestige = 1500
					}
					AND = {
						tier = EMPEROR
						prestige = 2000
					}
				}
			}
			custom_tooltip = {
				text = HAS_ANOTHER_ELIGIBLE_HEIR
				hidden_tooltip = {
					any_dynasty_member = {
						OR = {
							AND = {
								is_female = no
								has_law = agnatic_succession
							}
							NOT = { has_law = agnatic_succession}
						}
						is_adult = yes
						religion = FROM
						culture = FROM
						dynasty = FROM
						OR = {
							is_child_of = FROM
							mother_even_if_dead = { is_child_of = FROM }
							father_even_if_dead = { is_child_of = FROM }
						}
						NOT = {
							character = ROOT
							trait = incapable
							trait = lunatic
							trait = possessed
							trait = eunuch
							trait = blinded
						}
					}
				}
			}
		}
		effect = {
			FROM = {
				set_character_flag = disinherited_child
				if = {
					limit = { tier = COUNT }
					prestige = -250
				}
				if = {
					limit = { tier = DUKE }
					prestige = -500
				}
				if = {
					limit = { tier = KING }
					prestige = -750
				}
				if = {
					limit = { tier = EMPEROR }
					prestige = -1000
				}
				character_event = { id = Plus.1100 tooltip = consider_disinheritance }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				reverse_opinion = { who = FROM value = 25 }
				FROM = {
					NOT = {
						trait = cruel
						trait = ambitious
						trait = diligent
					}
				}
			}
			modifier = {
				factor = 0
				NOT = {
					NOT = { dynasty = FROM }
					NOT = { religion = FROM }
					trait = incapable
					trait = lunatic
					trait = possessed
					NOT = { reverse_opinion = { who = FROM value = -75 } }
					AND = {
						NOT = { num_of_children = 1 }
						NOT = { fertility = 0.05 }
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					NOT = {
						any_dynasty_member = {
							any_pretender_title = {
								is_primary_holder_title = yes
								holder = FROM
							}
							is_adult = yes
							religion = FROM
							culture = FROM
							dynasty = FROM
							OR = {
								is_child_of = FROM
								mother_even_if_dead = { is_child_of = FROM }
								father_even_if_dead = { is_child_of = FROM }
							}
							OR = {
								is_ruler = no
								same_realm = FROM
								lower_tier_than = FROM
							}
							OR = {
								num_of_children = 1
								fertility = 0.05
							}
							reverse_opinion = { who = FROM value = 0 }
							NOT = {
								character = ROOT
								trait = bastard
								trait = incapable
								trait = lunatic
								trait = possessed
							}
						}
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = slothful
						trait = content
						trait = just
					}
				}
			}
		}
	}

	reconcile_child = {
		filter = dynasty
		ai_target_filter = dynasty
		ai_check_interval = 12
		only_playable = yes
		only_rulers = yes
		
		from_potential = {
			is_ruler = yes
			is_playable = yes
			has_regent = no
			had_character_flag = { flag = disinherited_child days = 365 }
		}
		potential = {
			is_child_of = FROM
			trait = disinherited
			same_realm = FROM
			dynasty = FROM
			religion = FROM
			prisoner = no
			reverse_opinion = { who = FROM value = 0 }
			OR = {
				num_of_children = 1
				fertility = 0.05
			}
			NOT = {
				trait = incapable
				trait = lunatic
				trait = possessed
			}
		}
		allow = {
			ROOT = {
				trait = disinherited
			}
			FROM = {
				war = no
				OR = {
					AND = {
						tier = COUNT
						prestige = 250
					}
					AND = {
						tier = DUKE
						prestige = 500
					}
					AND = {
						tier = KING
						prestige = 750
					}
					AND = {
						tier = EMPEROR
						prestige = 1000
					}
				}
			}
		}
		effect = {
			FROM = {
				if = {
					limit = { tier = COUNT }
					prestige = -125
				}
				if = {
					limit = { tier = DUKE }
					prestige = -250
				}
				if = {
					limit = { tier = KING }
					prestige = -375
				}
				if = {
					limit = { tier = EMPEROR }
					prestige = -500
				}
				character_event = { id = Plus.1120 tooltip = consider_reconciliation }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROM = {
					current_heir = {
						dynasty = FROM
						reverse_opinion = { who = FROM value = 50 }
					}
				}
			}
		}
	}

	grant_estate = {
		filter = sub_realm
		ai_target_filter = sub_realm
		
		from_potential = {
			ai = no
			wealth = 50
			is_tribal = no
			is_nomadic = no
		}
		potential = {
			is_adult = yes
			is_ruler = no
			is_liege_or_above = FROM
			NOT = { has_character_modifier = estates_5 }
		}
		allow = {
			ROOT = {
				prisoner = no
				NOT = { trait = incapable }
			}
			FROM = {
				war = no
			}
		}
		effect = {
			FROM = { character_event = { id = Plus.105 tooltip = CONSIDER_MINOR_ESTATE } }
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	pardon = {
		filter = sub_realm
		ai_target_filter = sub_realm
		
		from_potential = {
			ai = no
		}
		potential = {
			is_liege_or_above = FROM
			crime_against_FROM_trigger = yes
		}
		allow = {
			ROOT = {
				prisoner = no
			}
		}
		effect = {
			FROM = {
				if = {
					limit = {
						NOT = { trait = just }
						NOT = { trait = arbitrary }
					}
					random = {
						chance = 25
						add_trait = arbitrary
					}
				}
				if = {
					limit = { trait = just }
					random = {
						chance = 25
						remove_trait = just
					}
				}
			}
			opinion = {
				who = FROM
				modifier = opinion_relieved
				years = 5
			}
			pardon_effect = yes
		}
		ai_will_do = {
			factor = 0
		}
	}

	swear_to_heir = {
		filter = vassals
		ai_target_filter = vassals
		only_rulers = yes
		ai_check_interval = 12
		
		from_potential = {
			is_ruler = yes
			is_feudal = yes
			has_regent = no
			primary_title = {
				higher_real_tier_than = DUKE
				OR = {
					has_law = crown_authority_3
					has_law = crown_authority_4
				}
			}
		}
		potential = {
			ai = yes
			vassal_of = FROM
			higher_real_tier_than = BARON
			FROM = {
				current_heir = {
					NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = sworn_to_support_heir } }
				}
			}
			NOT = {
				is_primary_heir = FROM
				has_opinion_modifier = { who = FROM modifier = asked_to_support_heir }
				reverse_has_opinion_modifier = { who = FROM modifier = refused_to_support_heir }
			}
		}
		allow = {
			ROOT = {
				war = no
				has_regent = no
				opinion = { who = FROM value = 50 }
			}
			FROM = {
				war = no
				ruled_years = 10
				prestige = 500
				current_heir = {
					dynasty = PREV
				}
			}
		}
		effect = {
			if = {
				limit = { tier = COUNT }
				FROM = { prestige = -100 }
			}
			if = {
				limit = { tier = DUKE }
				FROM = { prestige = -250 }
			}
			if = {
				limit = { tier = KING }
				FROM = { prestige = -500 }
			}
			ROOT = { character_event = { id = Plus.1600 tooltip = ASKED_TO_SUPPORT_HEIR } }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				always = yes
			}
			modifier = {
				factor = 5
				tier = KING
			}
			modifier = {
				factor = 2
				tier = DUKE
			}
			modifier = {
				factor = 0.5
				tier = COUNT
				FROM = { higher_tier_than = DUKE }
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 0
				FROM = { NOT = { age = 50 } }
			}
			modifier = {
				factor = 0
				FROM = { NOT = { prestige = 1000 } }
			}
			modifier = {
				factor = 0
				FROM = {
					current_heir = {
						NOT = { is_close_relative = PREV }
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						has_law = succ_gavelkind
						has_law = succ_elective_gavelkind
					}
					OR = {
						has_law = agnatic_succession
						has_law = cognatic_succession
					}
					any_child = {
						is_female = no
						NOT = { trait = bastard }
						count = 2
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						has_law = succ_gavelkind
						has_law = succ_elective_gavelkind
					}
					has_law = true_cognatic_succession
					any_child = {
						NOT = { trait = bastard }
						count = 2
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						has_law = succ_gavelkind
						has_law = succ_elective_gavelkind
					}
					OR = {
						has_law = enatic_succession
						has_law = enatic_cognatic_succession
					}
					any_child = {
						is_female = yes
						NOT = { trait = bastard }
						count = 2
					}
				}
			}
		}
	}
	
	request_holy_war = {	
		from_potential = {
			ai = no
			is_nomadic = no
			controls_religion = no
			rightful_religious_head_scope = {
				is_alive = yes
				NOT = { character = FROM }
			}
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				is_patrician = no
				independent = yes
			}
			NOT = {
				trait = excommunicated
				pacifist = yes
				has_character_modifier = holy_truce_timer
			}
		}
		potential = {
			independent = yes
			FROM = { top_liege = { religion_group = PREV } }
			OR = {
				NOT = { religion_group = FROM }
				is_heresy_of = FROM
				is_parent_religion = FROM
				FROM = {
					OR = {
						religion_group = muslim
						is_pagan_religion = yes
					}
					NOT = { religion = ROOT }
				}
			}
			OR = {
				FROM = {
					NOT = {
						religion = hindu
						religion = buddhist
					}
				}
				NOT = { religion_group = indian_group }
			}
			OR = {
				any_realm_province = {
					any_neighbor_province = {
						owner = {
							OR = {
								same_realm = FROM
								character = FROM
							}
						}
					}
				}
				any_realm_province = {
					FROM = { 
						any_realm_province = {
							NOT = {
								distance = { 
									where = PREVPREV
									value = 125
								}
							}
						}
					}
				}
			}
			NOR = {
				same_realm = FROM
				has_character_modifier = holy_truce_timer
				has_character_modifier = crusade_block_timer 
				has_landed_title = e_china_west_governor
			}			
		}
		allow = {
			FROM = {
				war = no
				has_called_crusade = no
				piety = 0
				NOT = { has_any_opinion_modifier = holy_war_sanction }
				rightful_religious_head_scope = { NOT = { has_opinion_modifier = { who = PREV modifier = asked_holy_sanction } } }
			}
		}
		effect = {
			save_event_target_as = sanction_target
			FROM = {
				save_event_target_as = sanction_requester
				rightful_religious_head_scope = { letter_event = { id = Plus.1650 tooltip = ASK_FOR_SANCTION } }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	demand_conversion_courtier = {
		filter = court
		ai_target_filter = court
		only_rulers = yes
		ai_check_interval = 12

		from_potential = {
			is_ruler = yes
			has_regent = no
			has_secret_religion = no
		}
		potential = {
			is_ruler = no
			can_change_religion = yes
			is_adult = yes
			liege = { character = FROM }
			OR = {
				prisoner = no
				host = { character = FROM }
			}
			OR = {
				NOT = {
					has_opinion_modifier = { who = FROM modifier = tried_to_convert_me }
					has_opinion_modifier = { who = FROM modifier = opinion_mutual_respect }
					has_opinion_modifier = { who = FROM modifier = opinion_demanded_conversion }
				}
				prisoner = yes
			}
			OR = {
				NOT = {
					has_character_modifier = planning_claimant_adventure
					any_spouse = { has_character_modifier = planning_claimant_adventure }
					father = { has_character_modifier = planning_claimant_adventure }
					mother = { has_character_modifier = planning_claimant_adventure }
				}
				prisoner = yes
			}
			NOT = {
				trait = incapable
				religion = FROM
				any_liege = { holy_order = yes }
				any_liege = { mercenary = yes }
				has_character_flag = considering_conversion
			}
		}
		allow = {
			ROOT = {
				NOT = { trait = zealous }
				NOT = { trait = possessed }
				NOT = { trait = lunatic }
				NOT = { trait = shiite_claimant }
				war = no
				custom_tooltip = {
					text = IS_NOT_BUSY
					hidden_tooltip = {
						is_not_busy_trigger = yes
						NOT = { is_inaccessible_trigger = yes }
						in_command_trigger = no
					}
				}
			}
			FROM = {
				war = no
				custom_tooltip = {
					text = IS_NOT_BUSY
					hidden_tooltip = {
						is_not_busy_trigger = yes
						NOT = { is_inaccessible_trigger = yes }
						in_command_trigger = no
					}
				}
				piety = 10
				NOT = { trait = excommunicated }
			}
		}
		effect = {
			FROM = {
				piety = -10
				if = {
					limit = {
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
					}
					prestige = -20
				}
			}
			ROOT = {
				set_character_flag = considering_conversion
				if = {
					limit = { prisoner = yes }
					custom_tooltip = { text = WILL_BE_RELEASED_ON_CONVERT }
				}
				if = {
					limit = { prisoner = no }
					custom_tooltip = { text = CONVERSION_DIPLOMACY_POSSIBLE }
					if = {
						limit = { FROM = { learning = 8 } }
						custom_tooltip = { text = CONVERSION_DEBATE_POSSIBLE }
					}
					if = {
						limit = { FROM = { NOT = { learning = 8 } } }
						custom_tooltip = { text = CONVERSION_DEBATE_NOT_POSSIBLE }
					}
					if = {
						limit = {
							FROM = {
								OR = {
									AND = {
										is_tribal = no
										crownlaw_title = {
											OR = {
												has_law = crown_authority_2
												has_law = crown_authority_3
												has_law = crown_authority_4
											}
										}
									}
									AND = {
										is_tribal = yes
										primary_title = {
											OR = {
												has_law = tribal_organization_2
												has_law = tribal_organization_3
												has_law = tribal_organization_4
											}
										}
									}
								}
							}
						}
						custom_tooltip = { text = CONVERSION_THREAT_POSSIBLE }
					}
					if = {
						limit = {
							FROM = {
								NOT = {
									AND = {
										is_tribal = no
										crownlaw_title = {
											OR = {
												has_law = crown_authority_2
												has_law = crown_authority_3
												has_law = crown_authority_4
											}
										}
									}
									AND = {
										is_tribal = yes
										primary_title = {
											OR = {
												has_law = tribal_organization_2
												has_law = tribal_organization_3
												has_law = tribal_organization_4
											}
										}
									}
								}
							}
						}
						custom_tooltip = { text = CONVERSION_THREAT_NOT_POSSIBLE }
					}
				}
			}
			hidden_tooltip = {
				FROM = { character_event = { id = GoPagan.130 } }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROM = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					OR = {
						NOT = { trait = zealous }
						NOT = { prestige = 50 }
					}
				}
			}
			modifier = {
				factor = 0
				prisoner = no
				NOT = { reverse_opinion = { who = FROM value = 25 } }
				FROM = {
					NOR = {
						trait = cruel
						trait = wroth
						trait = zealous
						trait = impaler
					}
				}
			}
			modifier = {
				factor = 0
				FROM = { trait = cynical }
			}
			modifier = {
				factor = 5
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 0
				NOT = { piety = 100 }
			}
			modifier = {
				factor = 5
				prisoner = yes
			}
		}
	}
	
	demand_conversion_vassal = {
		filter = vassals
		ai_target_filter = vassals
		ai_check_interval = 12
		only_rulers = yes

		from_potential = {
			is_ruler = yes
			has_regent = no
		}
		potential = {
			is_ruler = yes
			can_change_religion = yes
			holy_order = no
			mercenary = no
			is_adult = yes
			vassal_of = FROM
			OR = {
				prisoner = no
				host = { character = FROM }
			}
			OR = {
				NOT = {
					has_opinion_modifier = { who = FROM modifier = tried_to_convert_me }
					has_opinion_modifier = { who = FROM modifier = opinion_mutual_respect }
					has_opinion_modifier = { who = FROM modifier = opinion_demanded_conversion }
				}
				prisoner = yes
			}
			is_theocracy = no
			NOT = {
				trait = incapable
				religion = FROM
				has_character_flag = considering_conversion
			}
		}
		allow = {
			ROOT = {
				NOT = { trait = zealous }
				NOT = { trait = possessed }
				NOT = { trait = lunatic }
				NOT = { trait = shiite_claimant }
				war = no
				custom_tooltip = {
					text = IS_NOT_BUSY
					hidden_tooltip = {
						is_not_busy_trigger = yes
						NOT = { is_inaccessible_trigger = yes }
						in_command_trigger = no
					}
				}
			}
			FROM = {
				war = no
				custom_tooltip = {
					text = IS_NOT_BUSY
					hidden_tooltip = {
						is_not_busy_trigger = yes
						NOT = { is_inaccessible_trigger = yes }
						in_command_trigger = no
					}
				}
				piety = 50
				NOT = { trait = excommunicated }
			}
		}
		effect = {
			FROM = {
				piety = -50
				if = {
					limit = {
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
					}
					if = {
						limit = { ROOT = { lower_tier_than = DUKE } }
						prestige = -50
					}
					if = {
						limit = { ROOT = { higher_tier_than = COUNT } }
						prestige = -100
					}
				}
			}
			ROOT = {
				set_character_flag = considering_conversion
				if = {
					limit = { prisoner = yes }
					custom_tooltip = { text = WILL_BE_RELEASED_ON_CONVERT }
				}
				if = {
					limit = { prisoner = no }
					custom_tooltip = { text = CONVERSION_DIPLOMACY_POSSIBLE }
					if = {
						limit = { FROM = { learning = 8 } }
						custom_tooltip = { text = CONVERSION_DEBATE_POSSIBLE }
					}
					if = {
						limit = { FROM = { NOT = { learning = 8 } } }
						custom_tooltip = { text = CONVERSION_DEBATE_NOT_POSSIBLE }
					}
					if = {
						limit = {
							FROM = {
								OR = {
									AND = {
										is_tribal = no
										crownlaw_title = {
											OR = {
												has_law = crown_authority_2
												has_law = crown_authority_3
												has_law = crown_authority_4
											}
										}
									}
									AND = {
										is_tribal = yes
										primary_title = {
											OR = {
												has_law = tribal_organization_2
												has_law = tribal_organization_3
												has_law = tribal_organization_4
											}
										}
									}
								}
							}
						}
						custom_tooltip = { text = CONVERSION_THREAT_POSSIBLE }
					}
					if = {
						limit = {
							FROM = {
								NOT = {
									AND = {
										is_tribal = no
										crownlaw_title = {
											OR = {
												has_law = crown_authority_2
												has_law = crown_authority_3
												has_law = crown_authority_4
											}
										}
									}
									AND = {
										is_tribal = yes
										primary_title = {
											OR = {
												has_law = tribal_organization_2
												has_law = tribal_organization_3
												has_law = tribal_organization_4
											}
										}
									}
								}
							}
						}
						custom_tooltip = { text = CONVERSION_THREAT_NOT_POSSIBLE }
					}
				}
			}
			hidden_tooltip = {
				FROM = { character_event = { id = GoPagan.130 } }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROM = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					OR = {
						NOT = { trait = zealous }
						NOT = { prestige = 200 }
					}
				}
			}
			modifier = {
				factor = 0
				prisoner = no
				NOT = { reverse_opinion = { who = FROM value = 25 } }
				FROM = {
					NOR = {
						trait = cruel
						trait = wroth
						trait = zealous
						trait = impaler
					}
				}
			}
			modifier = {
				factor = 0
				FROM = { trait = cynical }
			}
			modifier = {
				factor = 5
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 0
				NOT = { piety = 100 }
			}
			modifier = {
				factor = 5
				prisoner = yes
			}
		}
	}
	
	demand_conversion_prisoner = {
		filter = court
		ai_target_filter = court
		only_rulers = yes

		from_potential = {
			is_ruler = yes
			has_regent = no
		}
		potential = {
			is_ruler = yes
			can_change_religion = yes
			holy_order = no
			mercenary = no
			is_adult = yes
			NOT = { vassal_of = FROM }
			host = { character = FROM }
			prisoner = yes
			is_theocracy = no
			NOT = {
				trait = incapable
				religion = FROM
				has_character_flag = considering_conversion
			}
		}
		allow = {
			ROOT = {
				NOT = { trait = zealous }
				NOT = { trait = possessed }
				NOT = { trait = lunatic }
				NOT = { trait = shiite_claimant }
				war = no
				custom_tooltip = {
					text = IS_NOT_BUSY
					hidden_tooltip = {
						is_not_busy_trigger = yes
						NOT = { is_inaccessible_trigger = yes }
						in_command_trigger = no
					}
				}
			}
			FROM = {
				war = no
				custom_tooltip = {
					text = IS_NOT_BUSY
					hidden_tooltip = {
						is_not_busy_trigger = yes
						NOT = { is_inaccessible_trigger = yes }
						in_command_trigger = no
					}
				}
				piety = 50
				NOT = { trait = excommunicated }
			}
		}
		effect = {
			FROM = {
				piety = -50
				if = {
					limit = {
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
					}
					if = {
						limit = { ROOT = { lower_tier_than = DUKE } }
						prestige = -50
					}
					if = {
						limit = { ROOT = { higher_tier_than = COUNT } }
						prestige = -100
					}
				}
			}
			ROOT = {
				set_character_flag = considering_conversion
				custom_tooltip = { text = WILL_BE_RELEASED_ON_CONVERT }
			}
			hidden_tooltip = {
				FROM = { character_event = { id = GoPagan.130 } }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	ai_divorce = {
		filter = spouse
		ai_target_filter = spouse
		only_rulers = yes
		ai_check_interval = 60
		
		from_potential = {
			ai = yes
			is_married = yes
			is_ruler = yes
			OR = {
				is_female = no
				is_married_matrilineally = yes
			}
			OR = {
				AND = {
					religion_head_divorce_trigger = yes
					rightful_religious_head_scope = { is_alive = yes }
					piety = 100
				}
				AND = {
					religion_head_divorce_trigger = yes
					OR = {
						controls_religion = yes
						rightful_religious_head = FROM
					}
					piety = 100
				}
				AND = {
					NOT = { religion_head_divorce_trigger = yes }
					scaled_wealth = 1.0
				}
				AND = {
					religion_head_divorce_trigger = yes
					controls_religion = no
					NOT = { rightful_religious_head_scope = { is_alive = yes } }
					scaled_wealth = 1.0
				}
			}
			NOR = {
				age = 60
				has_character_flag = usurped_by_husband
				has_character_flag = usurped_my_wife
				trait = incapable
				trait = zealous
			}
		}
		potential = {
			is_married = FROM
			is_ruler = no
			NOT = {
				is_lover = FROM
				is_friend = FROM
				any_child = {
					is_alive = yes
					is_female = no
					is_child_of = FROM
					NOT = { trait = bastard }
				}
			}
			FROM = {
				OR = {
					AND = {
						religion_head_divorce_trigger = yes
						controls_religion = yes
					}
					AND = {
						religion_head_divorce_trigger = yes
						rightful_religious_head_scope = { character = PREV }
					}
					AND = {
						religion_head_divorce_trigger = yes
						rightful_religious_head_scope = { opinion = { who = PREV value = 25 } }
					}
					AND = {
						NOT = { religion_head_divorce_trigger = yes }
						scaled_wealth = 1.0
					}
					AND = {
						religion_head_divorce_trigger = yes
						controls_religion = no
						NOT = { rightful_religious_head_scope = { is_alive = yes } }
						scaled_wealth = 1.0
					}
				}
			}
		}
		allow = {
			OR = {
				has_character_modifier = failed_to_usurp_wife
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_hate }
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_traitor }
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_rebel_traitor }
				reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder }
				reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder_of_child }
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_murder_attempt }
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_killed_close_kin }
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_witch }
				reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder_of_close_kin }
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_civil_war_loser }
				reverse_has_opinion_modifier = { who = FROM modifier = mad_heretic }
				AND = {
					is_rival = FROM
					NOT = { reverse_opinion = { who = FROM value = -50 } }
				}
				AND = {
					#can no longer have children
					OR = {
						trait = leper
						trait = incapable
						trait = celibate
						trait = eunuch
						reverse_has_opinion_modifier = { who = FROM modifier = knows_barren }
						age = 60
						AND = {
							age = 45
							is_female = yes
						}
					}
					#I can still have children
					FROM = {
						fertility = 0.05
						NOT = { age = 60 }
						OR = {
							is_female = no
							NOT = { age = 45 }
						}
					}
				}
			}
		}
		effect = {
			FROM = {
				prestige = -100
				if = {
					limit = {
						religion_head_divorce_trigger = yes
						rightful_religious_head_scope = { is_alive = yes }
					}
					piety = -100
				}
				if = {
					limit = {
						NOT = { religion_head_divorce_trigger = yes }
					}
					scaled_wealth = -1.0
				}
				if = {
					limit = {
						religion_head_divorce_trigger = yes
						NOT = { rightful_religious_head_scope = { is_alive = yes } }
					}
					scaled_wealth = -1.0
				}
				tooltip = { remove_spouse = ROOT }
			}
			character_event = { id = Plus.140 }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				always = yes
			}
			modifier = {
				factor = 100
				OR = {
					has_character_modifier = failed_to_usurp_wife
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_hate }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_traitor }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_rebel_traitor }
					reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder }
					reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder_of_child }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_murder_attempt }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_killed_close_kin }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_witch }
					reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder_of_close_kin }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_civil_war_loser }
					reverse_has_opinion_modifier = { who = FROM modifier = mad_heretic }
				}
			}
			modifier = {
				factor = 0.1
				reverse_opinion = { who = FROM value = 0 }
			}
			modifier = {
				factor = 0.1
				FROM = { trait = slothful }
			}
			modifier = {
				factor = 0.1
				FROM = { trait = trusting }
			}
			modifier = {
				factor = 10
				FROM = { trait = diligent }
			}
			modifier = {
				factor = 10
				FROM = { trait = ambitious }
			}
			modifier = {
				factor = 10
				FROM = {
					OR = {
						trait = cruel
						trait = greedy
						trait = cynical
						trait = paranoid
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = kind
						trait = humble
						trait = craven
						trait = content
					}
					NOT = {
						trait = diligent
						trait = ambitious
					}
				}
				NOT = {
					has_character_modifier = failed_to_usurp_wife
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_hate }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_traitor }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_rebel_traitor }
					reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder }
					reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder_of_child }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_murder_attempt }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_killed_close_kin }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_witch }
					reverse_has_opinion_modifier = { who = FROM modifier = attempted_murder_of_close_kin }
					reverse_has_opinion_modifier = { who = FROM modifier = opinion_civil_war_loser }
					reverse_has_opinion_modifier = { who = FROM modifier = mad_heretic }
				}
			}
		}
	}

	theocracy_banish_heretic = {
		filter = court
		ai_target_filter = court
		only_rulers = yes
		ai_check_interval = 12
		
		from_potential = {
			is_ruler = yes
			is_theocracy = yes
			is_heretic = no
			NOR = {
				trait = cynical
				trait = bad_priest_christian
				trait = bad_priest_muslim
				trait = bad_priest_norse
				trait = bad_priest_tengri
				trait = bad_priest_zoroastrian
				trait = bad_priest_aztec
			}
		}
		potential = {
			is_heresy_of = FROM
			is_ruler = no
			is_adult = yes
			prisoner = no
			employer = { character = FROM }
			NOT = { trait = incapable }
			NOT = { reverse_opinion = { who = FROM value = 25 } }
		}
		effect = {
			banish = yes
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 4
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 2
				FROM = { trait = wroth }
			}
			modifier = {
				factor = 2
				FROM = { trait = cruel }
			}
			modifier = {
				factor = 2
				FROM = { trait = diligent }
			}
			modifier = {
				factor = 0.5
				FROM = { trait = content }
			}
			modifier = {
				factor = 0.5
				FROM = { trait = slothful }
			}
			modifier = {
				factor = 0.5
				FROM = { trait = patient }
			}
			modifier = {
				factor = 0.25
				FROM = { trait = kind }
			}
		}
	}

	ruler_designer_customize = {
		filter = all
		ai_target_filter = self
		
		from_potential = {
			ai = no
			trait = customize_ruler
			NOR = {
				has_character_flag = customizing_ruler
				e_placeholder = { had_title_flag = { flag = startup days = 15 } }
			}
		}
		potential = {
			NOR = {
				dynasty = FROM
				dynasty = none
			}
		}
		allow = {
			OR = {
				culture = FROM
				AND = {
					culture_group = FROM
					FROM = { trait = legit_bastard }
				}
				AND = {
					FROM = { trait = bastard }
				}
			}
		}
		effect = {
			FROM = {
				set_character_flag = customizing_ruler
				if = {
					limit = { trait = bastard }
					character_event = { id = Plus.991 tooltip = CUSTOMIZE_RULER_BASTARD }
					break = yes
				}
				character_event = { id = Plus.991 tooltip = CUSTOMIZE_RULER_CHECK }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	seek_protection = {
		filter = all
		ai_target_filter = self
		
		only_independent = yes
		
		from_potential = {
			ai = no
			NOT = { has_character_flag = seeking_protection }
			NOT = { is_vassal_or_below = ROOT }
			NOT = { is_liege_or_above = ROOT }
			NOT = {
				rightful_religious_head_scope = {
					character = ROOT
				}
			}
			attacking_religious_head_trigger = no
			war = no
		}
		potential = {
			# The "attacker" needs a border, or be at most one sea zone away from one of the target's counties
			any_realm_province = {
				any_neighbor_province = {
					OR = {
						owner = { same_realm = FROM }
						AND = {
							is_land = no
							any_neighbor_province = {
								owner = { same_realm = FROM }
							}
						}
					}
				}
			}
			OR = {
				NOT = { has_character_flag = sought_protection_by_@FROM }
				had_character_flag = { flag = sought_protection_by_@FROM days = 1825 }
			}
			war = no
			NOT = { character = FROM }
			NOT = { has_landed_title = e_china_west_governor }
		}
		allow = {
			FROM = {
				has_dlc = "Horse Lords"
				higher_real_tier_than = BARON
				independent = yes
				is_tributary = no
				NOT = { higher_real_tier_than = ROOT }
			}
			ROOT = {
				relative_power = { who = FROM power = 3 }
				independent = yes
				is_tributary = no
			}
		}
		effect = {
			FROM = { character_event = { id = Plus.4040 days = 3 } }
			hidden_tooltip = {
				set_character_flag = sought_protection_by_@FROM
				FROM = { set_character_flag = seeking_protection }
			}
		}
		revoke_allowed = {
			always = no #Not used in vanilla
		}
		ai_will_do = {
			factor = 0
		}
	}

	demand_tribute = {
		filter = all
		ai_target_filter = self

		only_independent = yes
		from_potential = {
			ai = no		
			mercenary = no
			NOT = { has_character_flag = trying_to_gain_tributary }
			NOT = { is_vassal_or_below = ROOT }
			NOT = { is_liege_or_above = ROOT }
			NOT = {
				rightful_religious_head_scope = {
					character = ROOT
				}
			}
			attacking_religious_head_trigger = no
			
		}
		potential = {
			# The attacker needs a border, or be at most one sea zone away from one of the target's counties
			any_realm_province = {
				any_neighbor_province = {
					OR = {
						owner = { same_realm = FROM }
						AND = {
							is_land = no
							any_neighbor_province = {
								owner = { same_realm = FROM }
							}
						}
					}
				}
			}
			
			# The defender is not in any tributary war
			NOT = {
				any_war = {
					using_cb = tributary_cb
				}
			}
			war = no
			NOT = { character = FROM }
			NOT = { has_landed_title = e_china_west_governor }
		}
		allow = {
			FROM = {
				has_dlc = "Horse Lords"
				higher_real_tier_than = COUNT
				independent = yes
				NOT = { has_character_modifier = holy_truce_timer }
				NOT = { has_character_modifier = tributary_timer }
				is_tributary = no
				NAND = {
					holy_order = yes
					religion = ROOT
				}
			}
			ROOT = {
				NOT = { has_non_aggression_pact_with = FROM }
				NOT = { reverse_has_truce = FROM }
				NOT = { relative_power = { who = FROM power = 0.9 } }
				independent = yes
				NOR = {
					higher_tier_than = FROM
					pays_tribute_to = FROM
					any_liege = {
						pays_tribute_to = FROM
					}
					is_tributary = yes
				}
				NAND = {
					holy_order = yes
					religion = FROM
				}
			}
		}
		effect = {
			FROM = { character_event = { id = Plus.4000 days = 3} }
			hidden_tooltip = {
				FROM = { set_character_flag = trying_to_gain_tributary }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	vassalize_tributary = {
		filter = all
		ai_target_filter = self

		only_independent = yes
		from_potential = {
			ai = no
			independent = yes
			NOT = { has_character_modifier = holy_truce_timer }
			NOT = { has_character_modifier = tributary_timer }
			mercenary = no
			is_tributary = no
			has_dlc = "Horse Lords"
			NOT = { has_character_flag = trying_to_vassalize_tributary }
			NOT = {
				rightful_religious_head_scope = {
					character = ROOT
				}
			}
			attacking_religious_head_trigger = no
			NAND = {
				holy_order = yes
				religion = ROOT
			}
			is_feudal = yes
		}
		potential = {
			independent = yes
			pays_tribute_to = FROM
			OR = {
				is_tributary = { type = forced }
				is_tributary = { type = voluntary }
			}			

			war = no
			NOT = { character = FROM }
		}
		allow = {
			FROM = { higher_real_tier_than = COUNT }
			ROOT = {
				NOT = { has_non_aggression_pact_with = FROM }
				NOT = { reverse_has_truce = FROM }
				lower_tier_than = FROM
			}
			war = no
			custom_tooltip = {
				text = TRIBUTARY_FOR_30_YEARS
				hidden_tooltip = {
					primary_title = { check_variable = { which = "tributary_years" value = 30 } }
				}
			}
			FROM = {
				conditional_tooltip = {
					trigger = {
						tier = COUNT
					}
					prestige = 200
				}
				conditional_tooltip = {
					trigger = {
						tier = DUKE
					}
					prestige = 500
				}
				conditional_tooltip = {
					trigger = {
						tier = KING
					}
					prestige = 1200
				}
				conditional_tooltip = {
					trigger = {
						tier = EMPEROR
					}
					prestige = 2000
				}
			}
		}
		effect = {
			FROM = {
				if = {
					limit = { tier = COUNT }
					prestige = -200
				}
				else_if = {
					limit = { tier = DUKE }
					prestige = -500
				}
				else_if = {
					limit = { tier = KING }
					prestige = -1200
				}
				else_if = {
					limit = { tier = EMPEROR }
					prestige = -2000
				}	
				character_event = { id = Plus.4020 days = 3 }
			}
			hidden_tooltip = {
				FROM = { set_character_flag = trying_to_vassalize_tributary }
			}
		}
		revoke_allowed = {
			always = no #Not used in vanilla
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	release_as_protectorate = {
		filter = vassals
		ai_target_filter = self
		
		from_potential = {
			tier = EMPEROR
			has_imperial_government_trigger = yes
			primary_title = { is_titular = no }
			NOT = { has_character_modifier = holy_truce_timer }
			NOT = { has_character_modifier = tributary_timer }
		}

		potential = {
			NOT = { de_jure_liege_or_above = FROM }
			higher_real_tier_than = COUNT
			has_imperial_government_trigger = yes
		}
		
		allow = {
			war = no
			FROM = { war = no }
		}
		
        effect = {
			FROM = {
				if = {
					limit = { tier = COUNT }
					prestige = -200
				}
				else_if = {
					limit = { tier = DUKE }
					prestige = -500
				}
				else_if = {
					limit = { tier = KING }
					prestige = -1200
				}
				else_if = {
					limit = { tier = EMPEROR }
					prestige = -2000
				}	
				character_event = { id = Plus.4551 days = 3 }
			}
        }
		revoke_allowed = {
			always = no
		}		
		ai_will_do = {
			factor = 0
		}
	}
	
	prune_family_tree = {
		filter = dynasty_including_me #Filter characters targetted by the player
		ai_target_filter = self #Filter for characters targetted by the AI
		
		only_rulers = yes
		
		from_potential = {
			ai = no
			NOT = { dynasty = none }
		}
		
		potential = {
			dynasty = FROM
			num_of_children = 1
			any_child_even_if_dead = {
				is_alive = no
				has_children = no
				is_ruler = no
			}
		}
		allow = {
			always = yes
		}
		effect = {
			any_child_even_if_dead = {
				limit = {
					is_alive = no
					has_children = no
					is_ruler = no
				}
				set_father = 0
				set_mother = 0
				dynasty = none
			}
		}
		ai_will_do = {
			factor = 0
			#Factors for an AI character to take the decision (1 = 100% chance)
		}
	}
	
	grant_imperial_title = {
		filter = vassals #Filter characters targetted by the player
		ai_target_filter = self #Filter for characters targetted by the AI
		
		only_rulers = yes
		
		from_potential = {
			ai = no
			has_character_flag = must_grant_empire_flag
			any_demesne_title = {
				tier = EMPEROR
				is_titular = no
				count = 2
			}
		}
		
		potential = {
			always = yes
			NOT = { character = FROM }
		}
		allow = {			
			higher_real_tier_than = COUNT
			war = no
			mercenary = no
		}
		effect = {
			FROM = { character_event = { id = Plus.1871 } }
		}
		ai_will_do = {
			factor = 0
			#Factors for an AI character to take the decision (1 = 100% chance)
		}
	}
	
	reeducate_self = {
		filter = self
		ai_target_filter = self
		
		only_rulers = yes
		
		from_potential = {
			ai = no
		}
		potential = {
			age = 20
			is_dumb_trigger = no
			NOT = { has_character_modifier = being_reeducated }
			has_dlc = "Way of Life"
			NOT = { has_character_flag = was_reeducated }
		}
		allow = {
			war = no
			prisoner = no
			has_regent = no
			is_inaccessible_trigger = no
			NOR = {
				trait = humble
				trait = incapable
				trait = content
				trait = infirm
			}
			has_focus = focus_scholarship
			wealth = 50
			OR = {
				custom_tooltip = {
					text = NO_COURT_EDUCATOR
					hidden_tooltip = {
						NOT = {
							any_courtier_or_vassal = {
								liege = { character = ROOT }
								is_court_educator_trigger = yes
								NOT = { character = ROOT }
							}
						}
					}
				}
				custom_tooltip = {
					text = COURT_EDUCATOR_HAS_DIFFERENT_EDUCATION_FOCUS
					hidden_tooltip = {
						any_courtier_or_vassal = {
							liege = { character = ROOT }
							is_court_educator_trigger = yes
							NOT = { character = ROOT }
							has_prev_education_trigger = no
						}
					}
				}
				custom_tooltip = {
					text = COURT_EDUCATOR_HAS_BETTER_EDUCATION
					hidden_tooltip = {
						any_courtier_or_vassal = {
							liege = { character = ROOT }
							has_minor_title = title_court_educator
							NOT = { character = ROOT }
							has_prev_education_trigger = yes
							OR = {
								has_top_tier_education_trait_trigger = yes
								ROOT = { has_top_tier_education_trait_trigger = no }
							}
							OR = {
								has_tier_3_education_trigger = yes
								ROOT = {
									has_top_tier_education_trait_trigger = no
									has_tier_3_education_trigger = no
								}
							}
							OR = {
								has_tier_2_education_trigger = yes
								ROOT = {
									has_top_tier_education_trait_trigger = no
									has_tier_3_education_trigger = no
									has_tier_2_education_trigger = no
								}
							}
						}
					}
				}
			}
		}
		effect = {
			hidden_tooltip = {
				add_character_modifier = { name = being_reeducated duration = -1 }
				character_event = { id = Plus.1763 }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	rename_character_self = {
		filter = self
		ai_target_filter = self
		
		only_rulers = yes

		potential = {
			ai = no
			higher_real_tier_than = COUNT
			NOR = {
				has_character_flag = changed_name_once
				has_character_flag = renaming_character
			}
		}
		allow = {
			war = no
			prisoner = no
			has_regent = no
			is_inaccessible_trigger = no
		}
		effect = {
			set_character_flag = renaming_character
			character_event = { id = Plus.1800 }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}

	transfer_vassal_to_tributary = {
		filter = all #we could really use a "tributary" filter here.
		ai_target_filter = none
		third_party_filter = vassals
		
		potential = {
			independent = yes
			is_tributary = { suzerain = FROM }
		}
		from_potential = {
			ai = no
			independent = yes
			any_tributary = { always = yes }
		}
		third_party_potential = {
			FROMFROM = {
				NOT = { de_jure_liege_or_above = ROOT }
				higher_real_tier_than = BARON
				lower_tier_than = ROOT
			}
		}
		allow = {
			war = no
			FROM = { war = no }
		}
		third_party_allow = {
			FROMFROM = { war = no }
		}
		third_party_score = {
			factor = 1
			modifier = {
				factor = 2
				FROMFROM = { tier = DUKE }
			}
			modifier = {
				factor = 3
				FROMFROM = {
					num_of_duke_titles = 2
					tier = DUKE
				}
			}
			modifier = {
				factor = 4
				FROMFROM = { tier = KING }
			}
		}
		effect = {
			FROMFROM = {
				primary_title = { set_defacto_liege = ROOT }
			}
			opinion = {
				who = FROM
				modifier = opinion_vassal_transfer
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
}

decisions = {
	imperial_coronation = {
		is_high_prio = yes
		only_playable = yes
		
		potential = {
			OR = {
				trait = uncrowned
				AND = {
					trait = crowned
					has_landed_title = e_byzantium
					e_byzantium = { is_primary_holder_title = yes }
				}
			}
			is_feudal = yes
			is_landed = yes
			is_playable = yes
			real_tier = EMPEROR
			has_horde_culture = no
			is_nomadic = no
			NOR = {
				AND = {
					has_landed_title = e_byzantium
					e_byzantium = { is_primary_holder_title = yes }
					OR = {
						religion = orthodox
						religion = chalcedonian
					}
					d_pentarch_constantinople = {
						has_holder = yes
						holder_scope = {
							religion = ROOT
							NOT = { character = ROOT }
						}
					}
				}
				has_landed_title = e_hre
				has_landed_title = e_karling
				has_character_flag = planning_coronation
			}
		}
		allow = {
			war = no
			has_regent = no
			scaled_wealth = 1.0
			piety = 25
			is_adult = yes
			NOT = { trait = excommunicated }
			NOT = { has_character_modifier = in_seclusion }
			custom_tooltip = {
				text = HAS_BISHOP_WILLING_TO_CORONATE
				hidden_tooltip = {
					any_realm_character = {
						capital_holding = { holding_type = temple }
						is_ruler = yes
						is_adult = yes
						religion = ROOT
						prisoner = no
						NOT = { trait = incapable }
					}
				}
			}
			custom_tooltip = {
				text = IS_NOT_BUSY
				hidden_tooltip = {
					is_not_busy_trigger = yes
					NOT = { is_inaccessible_trigger = yes }
				}
			}
		}
		effect = {
			set_character_flag = planning_coronation
			scaled_wealth = -1.0
			character_event = { id = Plus.1200 } # send invitations
			hidden_tooltip = {
				add_character_modifier = {
					name = do_not_disturb
					duration = 200
					hidden = yes
				}
				character_event = { id = Plus.1290 days = 30 } # coronation start
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	royal_coronation = {
		is_high_prio = yes
		only_playable = yes
		
		potential = {
			trait = uncrowned
			is_feudal = yes
			is_landed = yes
			is_playable = yes
			real_tier = KING
			has_horde_culture = no
			is_nomadic = no
			primary_title = { is_vice_royalty = no }
			NOT = { has_character_flag = planning_coronation }
		}
		allow = {
			war = no
			has_regent = no
			scaled_wealth = 1.0
			piety = 25
			is_adult = yes
			NOT = { has_character_modifier = in_seclusion }
			NOT = { trait = excommunicated }
			custom_tooltip = {
				text = HAS_BISHOP_WILLING_TO_CORONATE
				hidden_tooltip = {
					any_realm_character = {
						capital_holding = { holding_type = temple }
						is_ruler = yes
						religion = ROOT
						is_adult = yes
						prisoner = no
						NOT = { trait = incapable }
					}
				}
			}
			custom_tooltip = {
				text = IS_NOT_BUSY
				hidden_tooltip = {
					is_not_busy_trigger = yes
					NOT = { is_inaccessible_trigger = yes }
				}
			}
		}
		effect = {
			set_character_flag = planning_coronation
			scaled_wealth = -1.0
			character_event = { id = Plus.1200 } # send invitations
			hidden_tooltip = {
				add_character_modifier = {
					name = do_not_disturb
					duration = 200
					hidden = yes
				}
				character_event = { id = Plus.1290 days = 30 } # coronation start
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	give_to_charity = {
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			is_ruler = yes
			has_regent = no
			demesne_size = 1
			NOT = { religion = sunni }
			NOT = { religion = shiite }
		}
		allow = {
			treasury = 50
			custom_tooltip = {
				text = RECENTLY_GAVE_TO_CHARITY
				hidden_tooltip = {
					NOT = { has_character_modifier = charity_timer }
				}
			}
		}
		effect = {
			treasury = -50
			piety = 25
			if = {
				limit = { any_vassal = { leads_faction = faction_tradition } }
				custom_tooltip = { text = TRADITIONFACTIONMOODPLUS }
				hidden_tooltip = {
					random_vassal = { limit = { leads_faction = faction_tradition } set_variable = { which = "faction_mood_increase" value = 1 } }
					character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
				}
			}
			hidden_tooltip = {
				if = {
					limit = { ai = no }
					add_character_modifier = {
						name = charity_timer
						duration = 1095
						hidden = yes
					}
				}
				if = {
					limit = { ai = yes }
					add_character_modifier = {
						name = charity_timer
						duration = 3650
						hidden = yes
					}
				}
			}
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0
				piety = 0
				OR = {
					trait = cynical
					trait = cruel
					trait = greedy
					lower_tier_than = duke
				}
			}
			modifier = {
				factor = 0
				piety = 100
			}
			modifier = {
				factor = 0
				piety = 0
				NOT = { treasury = 200 }
			}
			modifier = {
				factor = 0
				piety = 0
				has_character_modifier = ai_austerity
			}
		}
	}

	bring_children_to_court = {
		is_high_prio = yes
		only_rulers = yes
		potential = {
			ai = no
			any_child = {
				is_adult = no
				is_ruler = no
				prisoner = no
				NOT = {
					trait = bastard
					any_liege = { character = ROOT }
				}
			}
		}
		allow = {
			any_child = {
				is_adult = no
				is_ruler = no
				prisoner = no
				NOT = { trait = bastard }
				opinion = { who = ROOT value = 0 }
				liege = {
					lower_tier_than = ROOT
					opinion = { who = ROOT value = 0 }
				}
			}
		}
		effect = {
			any_child = {
				limit = {
					is_adult = no
					is_ruler = no
					prisoner = no
					NOT = { trait = bastard }
					opinion = { who = ROOT value = 0 }
					liege = {
						lower_tier_than = ROOT
						opinion = { who = ROOT value = 0 }
					}
				}
				custom_tooltip = {
					text = CUSTOMTOOLTIP38
					hidden_tooltip = { banish = ROOT }
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	reclaim_titles_divorce = {
		is_high_prio = yes
		ai_check_interval = 12
		potential = {
			has_character_flag = usurped_by_husband
			OR = {
				any_independent_ruler = {
					has_character_flag = usurped_my_wife
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_divorced }
					NOT = { any_spouse = { character = ROOT } }
					ROOT = {
						any_claim = {
							ROOT = { has_strong_claim = PREV }
							holder_scope = { character = PREVPREVPREV }
						}
					}
				}
				any_independent_ruler = {
					any_vassal = {
						has_character_flag = usurped_my_wife
						reverse_has_opinion_modifier = { who = ROOT modifier = opinion_divorced }
						NOT = { any_spouse = { character = ROOT } }
						ROOT = {
							any_claim = {
								ROOT = { has_strong_claim = PREV }
								holder_scope = { character = PREVPREVPREV }
							}
						}
					}
				}
			}		
		}
		allow = {
			prisoner = no
			NOT = {
				trait = excommunicated
				trait = incapable
			}
		}
		effect = {
			clr_character_flag = usurped_by_husband
			random_independent_ruler = {
				limit = {
					has_character_flag = usurped_my_wife
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_divorced }
					NOT = { any_spouse = { character = ROOT } }
					ROOT = {
						any_claim = {
							ROOT = { has_strong_claim = PREV }
							holder_scope = { character = PREVPREVPREV }
						}
					}
				}
				clr_character_flag = usurped_my_wife
				character_event = { id = FemRule.310 tooltip = REGAIN_TITLES_DIVORCE }
			}
			any_independent_ruler = {
				limit = {
					any_vassal = {
						has_character_flag = usurped_my_wife
						reverse_has_opinion_modifier = { who = ROOT modifier = opinion_divorced }
						NOT = { any_spouse = { character = ROOT } }
						ROOT = {
							any_claim = {
								ROOT = { has_strong_claim = PREV }
								holder_scope = { character = PREVPREVPREV }
							}
						}
					}
				}
				random_vassal = {
					limit = {
						has_character_flag = usurped_my_wife
						reverse_has_opinion_modifier = { who = ROOT modifier = opinion_divorced }
						NOT = { any_spouse = { character = ROOT } }
						ROOT = {
							any_claim = {
								ROOT = { has_strong_claim = PREV }
								holder_scope = { character = PREVPREVPREV }
							}
						}
					}
					clr_character_flag = usurped_my_wife
					character_event = { id = FemRule.310 tooltip = REGAIN_TITLES_DIVORCE }
				}
			}
		}	
		ai_will_do = {
			factor = 1
		}
	}

	usurp_husband = {
		is_high_prio = yes
		ai_check_interval = 12
		potential = {
			is_female = yes
			has_character_flag = usurped_by_husband
			spouse = { has_character_flag = usurped_my_wife }
		}
		
		allow = {
			any_claim = {
				holder_scope = {
					NOT = {
						is_child_of = ROOT
						has_character_flag = usurped_my_wife
					}
					any_liege = {
						has_character_flag = usurped_my_wife
						spouse = { character = ROOT }
						ROOT = { has_strong_claim = PREVPREVPREV }
					}
				}
			}
		}	
		
		effect = {
			any_claim = {
				limit = {
					holder_scope = {
						NOT = {
							is_child_of = ROOT
							spouse = { character = ROOT }
						}
						any_liege = {
							has_character_flag = usurped_my_wife
							spouse = { character = ROOT }
							ROOT = { has_strong_claim = PREVPREVPREV }
						}
					}
				}
				hidden_tooltip = {
					holder_scope = { set_character_flag = wife_regained_title }
				}
				usurp_title_plus_barony_if_unlanded = ROOT
				any_claimant = {
					limit = { has_character_flag = wife_regained_title }
					clr_character_flag = wife_regained_title
					PREV = { remove_claim = PREV }
				}
			}
			hidden_tooltip = {
				spouse = {
					letter_event = { id = FemRule.312 }
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	request_important_prisoners = {
		is_high_prio = yes
		only_rulers = yes
		
		potential = {
			is_ruler = yes
			higher_tier_than = BARON
			any_realm_lord = {
				ai = yes
				NOT = { war_with = ROOT }
				is_liege_or_above = ROOT
				any_courtier = {
					prisoner = yes
					higher_tier_than = BARON
					war_with = ROOT
				}
			}
		}
		
		allow = {
			prisoner = no
			prestige = 0
		}
		
		effect = {
			any_realm_lord = {
				limit = {
					ai = yes
					NOT = { war_with = ROOT }
					is_liege_or_above = ROOT
					any_courtier = {
						prisoner = yes
						higher_tier_than = BARON
						war_with = ROOT
					}
				}
				any_courtier = {
					limit = {
						prisoner = yes
						higher_tier_than = BARON
						war_with = ROOT
					}
					hidden_tooltip = {
						prisoner = no
					}
					prisoner = ROOT
				}
			}
		}
		
		ai_will_do = {
			factor = 1
		}
	}

	fourth_crusade = {
		potential = {
			can_call_crusade = yes
			has_called_crusade = no
			is_heretic = no
			ai = yes
			OR = {
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			NOR = {
				trait = pf_loyalist
				trait = pf_rebel
				has_character_modifier = crusade_timer
				has_character_modifier = holy_truce_timer
				has_global_flag = fourth_crusade_happened
			}
			has_global_flag = catholic_crusade_failed
			496 = {
				kingdom = {
					any_independent_ruler = {
						496 = {
							owner = {
								OR = {
									character = PREVPREV
									same_realm = PREVPREV
								}
							}
						}
						NOT = { has_character_modifier = holy_truce_timer }
						prisoner = no
						NOT = { religion = ROOT }
						num_of_realm_counties = {
							value = 6
							title = PREV
						}
					}
				}
			}
		}
		allow = {
			trait = bad_priest_christian
			religion_authority = 0.4
		}
		effect = {
			set_global_flag = fourth_crusade_ongoing
			set_global_flag = fourth_crusade_happened
			496 = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = crusade
							target = PREVPREV
							thirdparty_title = PREV
						}
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	take_loan = {
		potential = {
			ai = no
			is_ruler = yes
			OR = {
				higher_tier_than = baron
				is_patrician = yes
			}
			NOT = { has_character_flag = offended_moneylenders }
			NOR = { 
				has_character_modifier = loan_50_hidden
				has_character_modifier = loan_100_hidden
				has_character_modifier = loan_200_hidden
				has_character_modifier = loan_400_hidden
				has_character_modifier = loan_600_hidden
				has_character_modifier = loan_800_hidden
				has_character_modifier = loan_1000_hidden
			}
		}
		allow = {
			is_ruler = yes
			is_nomadic = no
		}
		effect = {
			take_loan_effect = yes
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_50 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_50_hidden
		}
		allow = {
			wealth = 62.5
		}
		effect = {
			wealth = -62.5
			remove_character_modifier = loan_50
			hidden_tooltip = {
				remove_character_modifier = loan_50_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_100 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_100_hidden
		}
		allow = {
			wealth = 125
		}
		effect = {
			wealth = -125
			remove_character_modifier = loan_100
			hidden_tooltip = {
				remove_character_modifier = loan_100_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_200 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_200_hidden
		}
		allow = {
			wealth = 250
		}
		effect = {
			wealth = -250
			remove_character_modifier = loan_200
			hidden_tooltip = {
				remove_character_modifier = loan_200_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_400 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_400_hidden
		}
		allow = {
			wealth = 500
		}
		effect = {
			wealth = -500
			remove_character_modifier = loan_400
			hidden_tooltip = {
				remove_character_modifier = loan_400_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_600 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_600_hidden
		}
		allow = {
			wealth = 750
		}
		effect = {
			wealth = -750
			remove_character_modifier = loan_600
			hidden_tooltip = {
				remove_character_modifier = loan_600_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_800 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_800_hidden
		}
		allow = {
			wealth = 1000
		}
		effect = {
			wealth = -1000
			remove_character_modifier = loan_800
			hidden_tooltip = {
				remove_character_modifier = loan_800_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	repay_loan_1000 = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			NOT = { has_character_flag = loan_in_progress }
			has_character_modifier = loan_1000_hidden
		}
		allow = {
			wealth = 1250
		}
		effect = {
			wealth = -1250
			remove_character_modifier = loan_1000
			hidden_tooltip = {
				remove_character_modifier = loan_1000_hidden
			}
			if = {
				limit = { NOT = { has_character_modifier = borrowed_from_jews } }
				clr_character_flag = loan_taken
			}			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	ai_take_loan = {
		only_rulers = yes
		ai_check_interval = 6
		potential = {
			ai = yes
			is_ruler = yes
			is_nomadic = no
			NOT = { has_landed_title = e_mexikha }
			OR = {
				higher_tier_than = baron
				is_patrician = yes
			}
			NOT = { check_variable = { which = "loan_amount" value = 49.5 } }
		}
		allow = {
			OR = {
				AND = {
					prisoner = yes
					war = no
				}
				any_war = {
					OR = {
						attacker = {
							character = ROOT
							NOT = { war_score = -15 }
						}
						defender = {
							character = ROOT
							war_score = 15
						}
					}
				}
				AND = {
					tier = DUKE
					num_of_duke_titles = 2
					war = no
				}
				any_realm_title = { NOT = { higher_tier_than = count } is_occupied = yes }
				NOT = { wealth = 0 }
			}
		}
		effect = {
			take_loan_effect = yes
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	ai_repay_loan = {
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			ai = yes
			is_ruler = yes
			prisoner = no
			war = no
			check_variable = { which = "loan_amount" value = 49.5 }
		}
		allow = {
			wealth = 50
		}
		effect = {
			wealth = -50
			hidden_tooltip = { change_variable = { which = "loan_amount" value = -50 } }
			if = {
				limit = { NOT = { check_variable = { which = "loan_amount" value = 49.5 } } }
				remove_character_modifier = loan_timer
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}

	employ_chancellor = {
		only_rulers = yes
		potential = {
			ai = no
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_patrician = yes
			}
			num_of_baron_titles = 1
			NOT = { has_character_modifier = employment_timer }
		}
		allow = {
			custom_tooltip = { text = employ_once_per_month }
			treasury = 10
			NOT = { has_character_modifier = in_seclusion }
		}
		effect = {
			treasury = -10
			create_random_diplomat = {
				random_traits = yes
				dynasty = random
				female = no
			}
			new_character = {
				hidden_tooltip = {
					if ={
						limit = { ROOT = { religion_group = jewish_group } }
						random = {
							chance = 70
							add_trait = yehudi
						}
					}
					set_character_flag = yehudi_check
				}
				hidden_tooltip = {
					if = {
						limit = {
							religion_group = indian_group
						}
						add_trait = kshatriya
						character_event = { id = RoI.30121 }
					}
				}
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }			
			add_character_modifier = {
				name = employment_timer
				duration = 30
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	employ_soldier = {
		only_rulers = yes
		potential = {
			ai = no			
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_patrician = yes
			}
			num_of_baron_titles = 1
			NOT = { has_character_modifier = employment_timer }
		}
		allow = {
			custom_tooltip = { text = employ_once_per_month }
			treasury = 10
			NOT = { has_character_modifier = in_seclusion }
		}
		effect = {
			treasury = -10
			create_random_soldier = {
				random_traits = yes
				dynasty = random
				female = no
				attributes = {
					diplomacy = 2
					learning = 2
					stewardship = 2
					intrigue = 2
					martial = 8
				}
			}
			new_character = {
				remove_trait = weak
				remove_trait = slow
				remove_trait = imbecile
				remove_trait = dull
				
				remove_trait = mystic
				remove_trait = socializer
				remove_trait = gamer
				remove_trait = hedonist
				remove_trait = duelist
				remove_trait = hunter
				remove_trait = strategist
				remove_trait = administrator
				remove_trait = architect
				remove_trait = gardener
				remove_trait = schemer
				remove_trait = impaler
				remove_trait = seducer
				remove_trait = seductress
				remove_trait = theologian
				remove_trait = scholar
				
				random_list = { # Flavor Randomization
					35 = { 
						# Nothing
					}
					15 = {
						change_martial = 2
					}
					10 = {
						add_trait = robust
					}
					10 = {
						add_trait = duelist
					}
					10 = {
						add_trait = hunter
					}
					5 = {
						add_trait = strategist
					}
					5 = {
						change_martial = 4
					}
					5 = {
						if = {
							limit = {
								has_dlc = "Reapers"
							}
							add_trait = one_eyed
						}
					}
					5 = { 
						add_trait = shrewd
					}
				}
				hidden_tooltip = {
					if ={
						limit = { ROOT = { religion_group = jewish_group } }
						random = {
							chance = 70
							add_trait = yehudi
						}
					}
					set_character_flag = yehudi_check
				}
				hidden_tooltip = {
					if = {
						limit = {
							religion_group = indian_group
						}
						add_trait = kshatriya
						character_event = { id = RoI.30121 }
					}
				}
				set_character_flag = invited_soldier
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }
			add_character_modifier = {
				name = employment_timer
				duration = 30
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	employ_spymaster = {
		only_rulers = yes
		potential = {			
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_patrician = yes
			}
			num_of_baron_titles = 1
			NOT = { has_character_modifier = employment_timer }
		}
		allow = {
			custom_tooltip = { text = employ_once_per_month }
			treasury = 10
			NOT = { has_character_modifier = in_seclusion }
		}
		effect = {
			treasury = -10
			create_random_intriguer = {
				random_traits = yes
				dynasty = random
				female = no
			}
			new_character = {
				hidden_tooltip = {
					if ={
						limit = { ROOT = { religion_group = jewish_group } }
						random = {
							chance = 70
							add_trait = yehudi
						}
					}
					set_character_flag = yehudi_check
				}
				hidden_tooltip = {
					if = {
						limit = {
							religion_group = indian_group
						}
						add_trait = kshatriya
						character_event = { id = RoI.30121 }
					}
				}
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }
			add_character_modifier = {
				name = employment_timer
				duration = 30
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_courtier = {
					NOT = { is_married = ROOT }
					OR = {
						trait = amateurish_plotter
						trait = flamboyant_schemer
						trait = intricate_webweaver
						trait = elusive_shadow
					}
				}
			}
		}
	}

	employ_priest = {
		only_rulers = yes
		potential = {			
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_patrician = yes
				rightful_religious_head = ROOT
			}
			num_of_baron_titles = 1
			NOT = { has_character_modifier = employment_timer }
		}
		allow = {
			custom_tooltip = { text = employ_once_per_month }
			piety = 10
			NOT = { has_character_modifier = in_seclusion }
		}
		effect = {
			piety = -10
			if = {
				limit = { religion_allows_female_temple_holders = no }
				create_random_priest = {
					random_traits = yes
					dynasty = random
					female = no
					attributes = {
						diplomacy = 2
						learning = 8
						stewardship = 2
						intrigue = 2
						martial = 2
					}
				}
			}
			if = {
				limit = { religion_allows_female_temple_holders = yes }
				random_list = {
					50 = {
						create_random_priest = {
							random_traits = yes
							dynasty = random
							female = no
							attributes = {
								diplomacy = 2
								learning = 8
								stewardship = 2
								intrigue = 2
								martial = 2
							}
						}
					}
					50 = {
						create_random_priest = {
							random_traits = yes
							dynasty = random
							female = yes
							attributes = {
								diplomacy = 2
								learning = 8
								stewardship = 2
								intrigue = 2
								martial = 2
							}
						}
					}
				}
			}
			new_character = {
				remove_trait = slow
				remove_trait = imbecile
				remove_trait = dull
				
				remove_trait = mystic
				remove_trait = socializer
				remove_trait = gamer
				remove_trait = hedonist
				remove_trait = duelist
				remove_trait = hunter
				remove_trait = strategist
				remove_trait = administrator
				remove_trait = architect
				remove_trait = gardener
				remove_trait = schemer
				remove_trait = impaler
				remove_trait = seducer
				remove_trait = seductress
				remove_trait = theologian
				remove_trait = scholar
				
				random_list = { # Flavor Randomization
					35 = { 
						# Nothing
					}
					15 = {
						change_learning = 2
					}
					20 = {
						add_trait = theologian
					}
					5 = {
						add_trait = scholar
					}
					5 = {
						add_trait = mystic
					}
					10 = {
						change_learning = 4
					}
					5 = {
						change_learning = 6
					}
					5 = {
						add_trait = shrewd
					}
				}
				hidden_tooltip = {
					if = {
						limit = {
							religion_group = christian
							NOR = {
								religion = cathar
								religion = bogomilist
								religion = miaphysite
								religion = monophysite
							}
						}
						if = {
							limit = { is_female = no }
							change_learning = 1
							add_trait = monk
							set_character_flag = title_monk
							set_special_character_title = MONK_BROTHER
						}
						if = {
							limit = { is_female = yes }
							change_learning = 1
							add_trait = nun
							set_character_flag = title_nun
							set_special_character_title = NUN_SISTER
						}
					}
					if = {
						limit = {
							OR = {
								religion = miaphysite
								religion = monophysite
							}
						}
						if = {
							limit = { is_female = yes }
							add_trait = desert_mother
							set_character_flag = title_desert_mother
							set_special_character_title = DESERT_MOTHER_TITLE
						}
						if = {
							limit = { is_female = no }
							add_trait = desert_father
							set_character_flag = title_desert_father
							set_special_character_title = DESERT_FATHER_TITLE
						}
					}
					if = {
						limit = {
							OR = {
								religion = cathar
								religion = bogomilist
							}
						}
						remove_trait = incapable
						remove_trait = cynical
						remove_trait = lustful
						remove_trait = hedonist
						remove_trait = seducer
						remove_trait = seductress
						add_trait = zealous
						add_trait = perfecti
						set_character_flag = consolamentum_taken
						if = {
							limit = { is_female = no }
							set_character_flag = title_monk
							set_special_character_title = MONK_BROTHER
						}
						if = {
							limit = { is_female = yes }
							set_character_flag = title_nun
							set_special_character_title = NUN_SISTER
						}
					}
					if = {
						limit = { religion_group = jewish_group }
						random = {
							chance = 70
							add_trait = yehudi
						}
					}
					set_character_flag = yehudi_check
					if = { 
						limit = {
							OR = {
								religion = celtic_pagan
								religion = celtic_pagan_reformed
							}
						}
						add_trait = druid
					}
					if = {
						limit = { religion_group = indian_group }
						add_trait = brahmin
						character_event = { id = RoI.30121 }
					}
				}
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }
			add_character_modifier = {
				name = employment_timer
				duration = 30
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOR = {
					AND = {
						is_theocracy = yes
						NOT = {
							any_courtier = {
								religion = ROOT
								is_priest = yes
								count = 3
							}
						}
					}
					AND = {
						is_tribal = yes
						NOT = {
							any_courtier = {
								religion = ROOT
								culture = ROOT
								is_ruler = no
								has_job_title = no
								is_female = no
								is_adult = yes
								health = 4
								NOT = { trait = incapable }
								OR = {
									trait = detached_priest
									trait = martial_cleric
									trait = scholarly_theologian
									trait = mastermind_theologian
								}
							}
						}
					}
				}
			}
		}
	}
	
	employ_steward = {
		only_rulers = yes
		potential = {			
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_patrician = yes
			}
			num_of_baron_titles = 1
			NOT = { has_character_modifier = employment_timer }
		}
		allow = {
			custom_tooltip = { text = employ_once_per_month }
			treasury = 10
			NOT = { has_character_modifier = in_seclusion }
		}
		effect = {
			treasury = -10
			create_random_steward = {
				random_traits = yes
				dynasty = random
				female = no
				attributes = {
					diplomacy = 2
					learning = 2
					stewardship = 8
					intrigue = 2
					martial = 2
				}
			}
			new_character = {
				remove_trait = slow
				remove_trait = imbecile
				remove_trait = dull
				
				remove_trait = mystic
				remove_trait = socializer
				remove_trait = gamer
				remove_trait = hedonist
				remove_trait = duelist
				remove_trait = hunter
				remove_trait = strategist
				remove_trait = administrator
				remove_trait = architect
				remove_trait = gardener
				remove_trait = schemer
				remove_trait = impaler
				remove_trait = seducer
				remove_trait = seductress
				remove_trait = theologian
				remove_trait = scholar
				
				random_list = { # Flavor Randomization
					35 = { 
						# Nothing
					}
					15 = {
						change_stewardship = 2
					}
					10 = {
						add_trait = gardener
					}
					10 = {
						add_trait = architect
					}
					10 = {
						add_trait = administrator
					}
					10 = {
						change_stewardship = 4
					}
					5 = {
						change_stewardship = 6
					}
					5 = {
						add_trait = shrewd
					}
				}
				hidden_tooltip = {
					if ={
						limit = { ROOT = { religion_group = jewish_group } }
						random = {
							chance = 70
							add_trait = yehudi
						}
					}
					set_character_flag = yehudi_check
				}
				hidden_tooltip = {
					if = {
						limit = {
							religion_group = indian_group
						}
						add_trait = kshatriya
						character_event = { id = RoI.30121 }
					}
				}
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }
			add_character_modifier = {
				name = employment_timer
				duration = 30
				hidden = yes
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_courtier = {
					NOT = { is_married = ROOT }
					OR = {
						trait = indulgent_wastrel
						trait = thrifty_clerk
						trait = fortune_builder
						trait = midas_touched
					}
				}
			}
		}
	}
	
	present_debutante = {
		only_rulers = yes
		potential = {
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_patrician = yes
			}			
			is_adult = yes
			num_of_baron_titles = 1
			NOT = { has_character_modifier = employment_timer }
		}
		allow = {
			custom_tooltip = { text = employ_once_per_month }
			treasury = 10
			NOT = { has_character_modifier = in_seclusion }
		}
		effect = {
			treasury = -10
			create_character = {
				random_traits = yes
				dynasty = random
				female = yes
				age = 17
			}
			new_character = {
				remove_trait = slow
				remove_trait = imbecile
				remove_trait = dull
				hidden_tooltip = {
					if ={
						limit = { ROOT = { religion_group = jewish_group } }
						random = {
							chance = 70
							add_trait = yehudi
						}
					}
					set_character_flag = yehudi_check
				}
				hidden_tooltip = {
					if = {
						limit = {
							religion_group = indian_group
						}
						add_trait = kshatriya
						character_event = { id = RoI.30121 }
					}
				}
				set_character_flag = debutante
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }
			add_character_modifier = {
				name = employment_timer
				duration = 30
				hidden = yes
			}
			if = {
				limit = { ai = yes }
				set_character_flag = employed_debutante
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					has_character_flag = employed_debutante
					is_female = yes
					religion_group = muslim
					NOT = { has_ambition = obj_find_lover }
					NOT = { treasury = 100 }
				}
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	ransom_nonvassal = {
		potential = {
			ai = no
			any_courtier = {
				NOT = { same_realm = ROOT }
				prisoner = yes
				host = { character = ROOT }
			}
			NOT = { has_dlc = "Mystics" } # MnM has its own version
		}
		
		allow = {
			NOT = { has_character_modifier = ransom_timer }
		}
		
		effect = {
			add_character_modifier = {
				name = ransom_timer
				duration = 25
				hidden = yes
			}
			any_courtier = {
				limit = {
					NOT = { same_realm = ROOT }
					prisoner = yes
					host = { character = ROOT }
				}
				character_event = { id = Plus.985 days = 5 random = 12 tooltip = ransom_all_tooltip }
			}
		}
	}
	
	ransom_all = {
		potential = {
			ai = no
			any_courtier = {
				prisoner = yes
				host = { character = ROOT }
			}
			NOT = { has_dlc = "Mystics" } # MnM has its own version
		}
		
		allow = {
			NOT = { has_character_modifier = ransom_timer }
		}
		
		effect = {
			add_character_modifier = {
				name = ransom_timer
				duration = 25
				hidden = yes
			}
			any_courtier = {
				limit = {
					prisoner = yes
					host = { character = ROOT }
				}
				character_event = { id = Plus.985 days = 5 random = 12 tooltip = ransom_all_tooltip }
			}
		}
	}

	nhv_begin = {
		potential = {
			NOT = { has_character_modifier = nhv_explained }
		}
		allow = {
			ai = no
		}
		effect = {
			custom_tooltip = { text = NHV_BEGIN }
			hidden_tooltip = {
				narrative_event = { id = Plus.970 }
				add_character_modifier = {
					name = nhv_explained
					duration = -1
					hidden = yes
					inherit = yes
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	nhv_restart = {
		potential = {
			has_character_modifier = nhv_explained
			has_character_modifier = nhv_shut_off
		}
		allow = {
			ai = no
		}
		effect = {
			custom_tooltip = { text = NHV_RESTART_TOOLTIP }
			hidden_tooltip = {
				remove_character_modifier = nhv_shut_off
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	nhv_dist_all = { # Vassalize All
		potential = {
			has_character_modifier = nhv_explained	
			NOT = { has_character_modifier = nhv_shut_off }
		}
		allow = {
			OR = {
				AND = {
					has_dlc = "Zeus"
					has_regent = no
					hidden_tooltip = { # Hidden to reduce clutter
						age = 16
						NOT = { trait = incapable }
					}
					primary_title = { has_law = grant_title_voting_power_0 } # Council doesn't vote on granting count and higher titles
					higher_tier_than = COUNT
				}
				NOT = { has_dlc = "Zeus" }
			}
			custom_tooltip = {
				text = ONE_PROVINCE_FLAGGED
				hidden_tooltip = {
					any_demesne_province = {
						has_province_flag = keep_it
					}
				}
			}
			custom_tooltip = {
				text = CAN_DISTRIBUTE_TITLES
				hidden_tooltip = {
					OR = {
						any_demesne_title = {
							tier = baron
							is_capital = yes
							is_patrician = no
							location = { NOT = { has_province_flag = keep_it } }
						}
						any_demesne_title = {
							tier = baron
							is_capital = no
							is_patrician = no
							location = { NOT = { has_province_flag = keep_baronies } }
						}
					}
				}
			}
		}
		effect = {
			custom_tooltip = { text = nhv_county_dist1 }
			any_demesne_title = {
				limit = {
					tier = COUNT
					location = { has_province_flag = keep_it }
					location = { NOT = { has_province_flag = keep_baronies } }
				}
				custom_tooltip = { text = nhv_county_dist2 }
			}
			any_demesne_title = {
				limit = {
					tier = COUNT
					location = { has_province_flag = keep_baronies }
				}
				custom_tooltip = { text = nhv_barony_dist2 }
			}
			hidden_tooltip = {		
				character_event = { id = Plus.974 }	
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	nhv_dist_barons = { # Vassalize All Barons
		potential = {
			has_character_modifier = nhv_explained
			NOT = { has_character_modifier = nhv_shut_off }
		}
		allow = {
			custom_tooltip = {
				text = CAN_DISTRIBUTE_BARONY_TITLES
				hidden_tooltip = {
					any_demesne_title = {
						tier = baron
						is_capital = no
						is_patrician = no
						location = { NOT = { has_province_flag = keep_baronies } }
					}
				}
			}
		}
		effect = {
			if = {
				limit = { any_demesne_province = { has_province_flag = keep_baronies } }
				custom_tooltip = { text = nhv_barony_dist1 }
				any_demesne_title = {
					limit = {
						tier = COUNT
						location = { has_province_flag = keep_baronies }
					}
					custom_tooltip = { text = nhv_barony_dist2 }
				}
			}
			if = {
				limit = {
					NOT = { any_demesne_province = { has_province_flag = keep_baronies } }
				}
				custom_tooltip = { text = nhv_barony_dist3 }
			}
			hidden_tooltip = {		
				character_event = { id = Plus.975 }	
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	nhv_end = {
		potential = {
			has_character_modifier = nhv_explained
			NOT = { has_character_modifier = nhv_shut_off }
		}
		allow = {
			ai = no
		}
		effect = {
			custom_tooltip = { text = NHV_END_TOOLTIP }
			hidden_tooltip = {
				any_realm_province = {
					limit = { owner = { character = ROOT } }
					clr_province_flag = keep_it
					clr_province_flag = keep_baronies
				}
				add_character_modifier = {
					name = nhv_shut_off
					duration = -1
					hidden = yes
					inherit = yes
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	seek_ancient_knowledge = {
		only_playable = yes
		potential = {
			is_playable = yes
			is_heretic = no
			controls_religion = no
			NOT = {
				rightful_religious_head = ROOT
				has_dlc = "Way of Life"
				religion = jewish
				is_pagan_religion = yes
				religion_group = zoroastrian_group
				culture_group = mesoamerican
				culture_group = indo_aryan_group
				culture_group = dravidian_group
				capital_holding = { holding_type = temple }
				has_character_flag = seeks_pagan_knowledge
			}
		}
		
		allow = {
			war = no
			has_regent = no
			NOR = {
				trait = zealous
				is_dumb_trigger = yes
				has_character_modifier = voice_of_jesus
				has_character_modifier = voice_of_satan
			}
			OR = {
				trait = mystic
				trait = scholar
				AND = {
					trait = cynical
					learning = 10
				}
			}
		}
		
		effect = {
			set_character_flag = seeks_pagan_knowledge
			piety = -25
			custom_tooltip = { text = PURSUE_PAGAN_KNOWLEDGE }
		}
		
		ai_will_do = {
			factor = 0
		}
	}

	ai_request_holy_war = {	
		only_independent = yes
		ai_check_interval = 12
		potential = {
			ai = yes
			is_nomadic = no
			mercenary = no
			independent = yes
			higher_tier_than = COUNT
			num_of_count_titles = 1
			rightful_religious_head_scope = {
				is_alive = yes
				NOT = {
					has_opinion_modifier = { who = ROOT modifier = asked_holy_sanction }
					character = ROOT
				}
				OR = {
					ai = yes
					NOT = { has_character_flag = do_not_bug_me }
					had_character_flag = { flag = do_not_bug_me days = 365 }
				}
			}
			top_liege = { religion_group = ROOT }
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				is_patrician = no
				independent = yes
			}
			NOR = {
				religion_group = indian_group
				religion_group = jewish_group
				religion = orthodox
				religion = bogomilist
				religion = nestorian
				religion = monothelite
				religion = iconoclast
				culture_group = west_african
				culture_group = east_african
				trait = excommunicated
				trait = cynical
				pacifist = yes
				has_character_modifier = holy_truce_timer
				realm_size = 200
			}
		}
		allow = {
			war = no
			has_called_crusade = no
			piety = 0
			NOT = { has_any_opinion_modifier = holy_war_sanction }
			any_independent_ruler = {
				OR = {
					NOT = { religion_group = ROOT }
					is_heresy_of = ROOT
					is_parent_religion = ROOT
					ROOT = {
						OR = {
							religion_group = muslim
							is_pagan_religion = yes
						}
						NOT = { religion = PREV }
					}
				}
				OR = {
					ROOT = {
						NOT = {
							religion = hindu
							religion = buddhist
						}
					}
					NOT = { religion_group = indian_group }
				}
				OR = {
					ROOT = { NOT = { religion_group = christian } }
					NOT = { religion = tengri_pagan }
					has_global_flag = mongol_horde_arrival
				}
				OR = {
					any_realm_province = {
						any_neighbor_province = {
							has_province_flag = contingent_territory
							owner = {
								OR = {
									is_liege_or_above = ROOT
									character = ROOT
								}
							}
						}
					}
					any_realm_province = {
						ROOT = {
							any_realm_province = {
								has_province_flag = contingent_territory
								NOT = {
									distance = { 
										where = PREVPREV
										value = 75
									}
								}
							}
						}
					}
				}
				reverse_realm_levy_diff = { who = ROOT value = 3000 }
				NOT = {
					same_realm = ROOT
					has_character_modifier = holy_truce_timer
					has_character_modifier = crusade_block_timer
					reverse_has_truce = ROOT
					has_non_aggression_pact_with = ROOT
				}
			}
		}
		effect = {
			random_independent_ruler = {
				limit = {
					OR = {
						NOT = { religion_group = ROOT }
						is_heresy_of = ROOT
						is_parent_religion = ROOT
						ROOT = {
							OR = {
								religion_group = muslim
								is_pagan_religion = yes
							}
							NOT = { religion = PREV }
						}
					}
					OR = {
						ROOT = {
							NOT = {
								religion = hindu
								religion = buddhist
							}
						}
						NOT = { religion_group = indian_group }
					}
					OR = {
						ROOT = { NOT = { religion_group = christian } }
						NOT = { religion = tengri_pagan }
						has_global_flag = mongol_horde_arrival
					}
					OR = {
						any_realm_province = {
							has_province_flag = contingent_territory
							any_neighbor_province = {
								owner = {
									OR = {
										same_realm = ROOT
										character = ROOT
									}
								}
							}
						}
						any_realm_province = {
							has_province_flag = contingent_territory
							ROOT = { 
								any_realm_province = {
									NOT = {
										distance = { 
											where = PREVPREV
											value = 125
										}
									}
								}
							}
						}
					}
					reverse_realm_levy_diff = { who = ROOT value = 3000 }
					NOR = {
						same_realm = ROOT
						has_character_modifier = holy_truce_timer
						has_character_modifier = crusade_block_timer
						reverse_has_truce = ROOT
						has_non_aggression_pact_with = ROOT
					}
				}
				save_event_target_as = sanction_target
				log = "[Root.GetTitledName] asked [Root.RelHead.GetBestName] for permission to Holy War against [sanction_target.GetBestName]"
			}
			save_event_target_as = sanction_requester
			rightful_religious_head_scope = { letter_event = { id = Plus.1650 } }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				always = yes
			}
			modifier = {
				factor = 0.5
				NOT = { year = 1000 }
			}
			modifier = {
				factor = 5
				trait = zealous
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 0.5
				trait = content
			}
			modifier = {
				factor = 0.5
				trait = humble
			}
		}
	}

	claim_caliphate = {
		is_high_prio = yes
		ai_check_interval = 12
		
		potential = {
			religion_group = muslim
			is_feudal = yes
			is_female = no
			demesne_size = 1
			higher_tier_than = COUNT
			controls_religion = no
			dynasty_head = { character = ROOT }
			religion_head = {
				is_alive = yes
				NOT = { dynasty = ROOT }
			}
			NOR = {
				trait = decadent
				any_claim = { controls_religion = yes }
			}
		}
		allow = {
			war = no
			has_regent = no
			piety = 100
			NOR = {
				trait = dynasty_decadence_low
				trait = dynasty_decadence_med
				trait = dynasty_decadence_high
			}
			religion_head = {
				is_within_diplo_range = ROOT
				OR = {
					trait = dynasty_decadence_high
					trait = decadent
				}
			}
		}
		effect = {
			piety = -100
			religion_head = {
				random_demesne_title = {
					limit = { controls_religion = yes }
					add_claim = ROOT
				}
				hidden_tooltip = {
					character_event = { id = Plus.562 }
				}
			}
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.5
				lower_tier_than = KING
			}
			modifier = {
				factor = 0.1
				trait = humble
			}
			modifier = {
				factor = 0.1
				trait = content
			}
			modifier = {
				factor = 0.5
				trait = patient
			}
			modifier = {
				factor = 0.5
				trait = craven
			}
			modifier = {
				factor = 3
				trait = zealous
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 1.5
				trait = brave
			}
			modifier = {
				factor = 0
				trait = cynical
			}
			modifier = {
				factor = 0
				religion_head = {
					OR = {
						has_non_aggression_pact_with = ROOT
						is_allied_with = ROOT
						reverse_has_truce = ROOT
					}
				}
			}
		}
	}
	
	call_up_republic = {
		is_high_prio = yes
		ai_check_interval = 3
		potential = {
			is_merchant_republic = yes
			ai = no
			any_vassal = {
				is_patrician = yes
				prisoner = no
				ai = yes
				NOT = { has_character_modifier = defended_republic }
			}
			any_war = {
				NOT = {	using_cb = excommunicated_ruler }
				defender = { character = ROOT }
				attacker = {
					NOT = {
						has_opinion_modifier = { who = ROOT modifier = revolting_against }
						liege_before_war = { character = ROOT }
					}
				}
			}
			NOT = {
				has_earmarked_regiments = republic_defense
				realm_size = 30
			}
		}
		allow = {
			NOT = { realm_size = 30 }
			is_primary_war_defender = yes
			any_vassal = {
				is_patrician = yes
				prisoner = no
				custom_tooltip = {
					text = HAS_100_LEVIES
					hidden_tooltip = { realm_levies = 100 }
				}
				NOT = { has_character_modifier = defended_republic }
			}
		}
		effect = {
			capital_scope = {
				ROOT = {
					any_vassal = {
						limit = {
							is_patrician = yes
							prisoner = no
							realm_levies = 100
							ai = yes
							NOT = { has_character_modifier = defended_republic }
						}
						hidden_tooltip = {
							add_character_modifier = {
								name = defended_republic
								duration = 730
								inherit = yes
							}
						}
						spawn_unit = {
							province = PREVPREV
							owner = ROOT
							match_character = THIS
							match_mult = 0.75
							attrition = 1.0
							maintenance_multiplier = 1.0
							disband_on_peace = yes
							earmark = republic_defense
						}
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	create_caliphate = {
		is_high_prio = yes
		ai_check_interval = 12
		only_independent = yes
		potential = {
			religion_group = muslim
			is_feudal = yes
			is_female = no
			demesne_size = 1
			higher_tier_than = COUNT
			controls_religion = no
			dynasty_head = { character = ROOT }
			OR = {
				AND = {
					religion = hurufi
					NOT = { is_title_active = d_hurufi }
				}
				AND = {
					religion = druze
					NOT = { is_title_active = d_druze }
				}
				AND = {
					religion = kharijite
					NOT = { is_title_active = d_kharijite }
				}
				AND = {
					religion = zikri
					NOT = { is_title_active = d_zikri }
				}
				AND = {
					religion = ibadi
					NOT = { is_title_active = d_ibadi }
				}
			}
			NOR = {
				trait = decadent
				any_claim = { controls_religion = yes }
			}
		}
		allow = {
			war = no
			has_regent = no
			NOR = {
				trait = dynasty_decadence_low
				trait = dynasty_decadence_med
				trait = dynasty_decadence_high
			}
			is_heretic = no
			is_adult = yes
			OR = {
				religion = druze
				trait = mirza
				trait = sayyid
				piety = 1000
			}
			OR = {
				NOT = { religion = druze }
				AND = {
					piety = 1000
					trait = druze_ajawid
					num_of_holy_sites = 1 
					higher_tier_than = DUKE 
				}
			}
			OR = {
				religion = druze
				AND = {
					trait = sayyid
					piety = 1000
				}
				custom_tooltip = {
					text = controls_mecca_medina
					hidden_tooltip = {
						719 = { # Mecca
							owner = {
								OR = {
									is_liege_or_above = ROOT
									character = ROOT
								}
							}
						}
						718 = { # Medina
							owner = {
								OR = {
									is_liege_or_above = ROOT
									character = ROOT
								}
							}
						}
					}
				}
				custom_tooltip = {
					text = controls_jerusalem_damascus_baghdad
					hidden_tooltip = {
						774 = { # Jerusalem
							owner = {
								OR = {
									is_liege_or_above = ROOT
									character = ROOT
								}
							}
						}
						728 = { # Damascus
							owner = {
								OR = {
									is_liege_or_above = ROOT
									character = ROOT
								}
							}
						}
						693 = { # Baghdad
							owner = {
								OR = {
									is_liege_or_above = ROOT
									character = ROOT
								}
							}
						}
					}
				}
			}
		}
		effect = {
			trigger_switch = {
				on_trigger = religion
				hurufi = {
					activate_title = { title = d_hurufi status = yes }
					d_hurufi = { 
						grant_title_no_opinion = ROOT
						make_primary_title = yes
					}
				}
				ibadi = {
					activate_title = { title = d_ibadi status = yes }
					d_ibadi = { 
						grant_title_no_opinion = ROOT
						make_primary_title = yes
					}
				}
				zikri = {
					activate_title = { title = d_zikri status = yes }
					d_zikri = { 
						grant_title_no_opinion = ROOT
						make_primary_title = yes
					}
				}
				druze = {
					activate_title = { title = d_druze status = yes }
					d_druze = { 
						grant_title_no_opinion = ROOT
						make_primary_title = yes
					}
				}
				kharijite = {
					activate_title = { title = d_kharijite status = yes }
					d_kharijite = { 
						grant_title_no_opinion = ROOT
						make_primary_title = yes
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				lower_tier_than = KING
			}
			modifier = {
				factor = 0.1
				trait = humble
			}
			modifier = {
				factor = 0.1
				trait = content
			}
			modifier = {
				factor = 0.5
				trait = patient
			}
			modifier = {
				factor = 0.5
				trait = craven
			}
			modifier = {
				factor = 3
				trait = zealous
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 1.5
				trait = brave
			}
			modifier = {
				factor = 0
				trait = cynical
			}
		}
	}
}

