targetted_decisions = {

	RR_religion_sexual_decision_self = {
		ai_check_interval = 12 #check once a year
		filter = self
		ai_target_filter = self

		potential = {
			always = no
			has_religion_feature = RR_religion_sexual
			NOT = { trait = lustful }
			age = 16
		}
		allow = {
			NOT = { trait = chaste }
			piety = 50
		}
		effect = {
			piety = -50
			add_trait = lustful
			if = {
				limit = { 
					ai = no
					NOT = { trait = arbitrary }
				}
				random = {
					chance = 5
					add_trait = arbitrary
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.25 #Every year 25% of the eligible AI characters that aren't yet lustful will take the decision.
			}
		}
	}


	RR_religion_replace_high_priest = {
		ai_check_interval = 12 #check once a year
		filter = vassals
		ai_target_filter = vassals

		from_potential = {
			is_liege_of = ROOT
		}
		potential = {
				controls_religion = yes
				independent = no
				government = theocracy_government
				liege = { religion = prev }
				OR = {
					has_religion_feature = religion_autocephaly
					religion = orthodox
					religion = monothelite
					religion = iconoclast
					religion = paulician
					religion = miaphysite
					religion = monophysite
				}
		}
		allow = {
			FROM = { prestige = 1000 }
		}
		effect = {
			abdicate = yes
			FROM = { piety = -500 }
			ROOT = { prestige = -500 }
			opinion = {
				modifier = opinion_revoked_my_title
				who = FROM
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = { # AI will not replace vassal priests if priest and liege both have positive opinion of each other.
				factor = 0
				opinion = {
					who = ROOT
					value = 1
				}
				reverse_opinion = {
					who = ROOT
					value = 1
				}
			}
			modifier = { # AI lieges are less likely to repalce a vassal priest that they like.
				factor = 0.1
				opinion = {
					who = ROOT
					value = 0
				}
			}
			modifier = { # AI lieges are less likely to repalce a vassal priest that likes them.
				factor = 0.1
				reverse_opinion = {
					who = ROOT
					value = 0
				}
			}
		}
	}

	RR_sacrifice_child_decision = {
		only_playable = yes
		ai_check_interval = 12 #check once a year
	    diplomacy_icon = GFX_sacrifice_decision
	
		ai_target_filter = home_court
	
		from_potential = {
			show_only_failed_conditions = yes
			is_playable = yes
			has_religion_feature = religion_ritual_sacrifice
		}
	
		potential = {
			is_child_of = FROM
			is_adult = no
			host = { character = FROM }
			is_ruler = no

		}
		
		allow = {
			ROOT = {
				NOT = { diplomatic_immunity = yes }
			}
		}
		
		effect = {
			hidden_tooltip = {
				FROM = {
					character_event = { id = HF.23002 }
				}
			}
			death = {
				death_reason = death_execution_aztec_sacrifice
				killer = FROM
			}
			FROM = {
				show_scope_change = no
				if = {
					limit = {
						trait = kind
					}
					RR_stress_effect = yes
					remove_trait = kind
				}
				else_if = {
					limit = {
						NOR = {
							trait = cruel
							trait = impaler
							trait = possessed
						}
					}
					random = {
						chance = 50
						RR_stress_effect = yes
					}
				}
				else = {
					random = {
						chance = 25
						RR_stress_effect = yes
					}
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = { # Please don't kill eligible heirs.
				factor = 0
				is_female = yes
				NOT = { trait = bastard }
				FROM = {
					OR = { 
						has_law = enatic_succession
						has_law = enatic_cognatic_succession
						has_law = true_cognatic_succession
					} 
				}
			}
			modifier = { # Please don't kill eligible heirs.
				factor = 0
				is_female = no
				NOT = { trait = bastard }
				FROM = {
					OR = { 
						has_law = agnatic_succession
						has_law = cognatic_succession
						has_law = true_cognatic_succession
					} 
				}
			}
			modifier = { # Don't kill useful children.
				factor = 0
				OR = {
					has_positive_congenital_trigger = yes
					num_claims >= 1
				}
			}
			modifier = { # Clean up the gene pool.
				factor = 10
				has_negative_congenital_trigger = yes
			}
			modifier = {
				factor = 0.1
				FROM = {
					NOR = {
						trait = cruel
						trait = impaler
					}
				}
			}
			modifier = {
				factor = 0.1
				FROM = {
					NOR = {
						trait = lunatic
						trait = possessed
					}
				}
			}
			modifier = {
				factor = 2
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 2
				FROM = { trait = bloodthirsty_gods_1 }
			}
			modifier = {
				factor = 2
				FROM = { trait = bloodthirsty_gods_2 }
			}
			modifier = {
				factor = 2
				FROM = { trait = bloodthirsty_gods_3 }
			}
		}
	}

}

decisions = {

	RR_religion_joy_decision = {
		is_high_prio = yes
		ai_check_interval = 1 #check once a year

		potential = {
			OR = {
				has_joy = yes
			}
		}
		allow = {
			age = 16
			OR = {
				trait = depressed
				trait = stressed
				NOR = { # The bonuses you get if you take the decision and you aren't stressed/depressed.
					has_character_modifier = RR_modifier_joy
					has_character_modifier = RR_modifier_joy_family
					has_character_modifier = RR_modifier_joy_friends
				}
			}
		}
		effect = {
			hidden_tooltip = { character_event = { id = RR.100 } }
			custom_tooltip = { text = RR_religion_joy_decision_custom_tooltip }
		}
		ai_will_do = {
			factor = 1
		}
	}

	RR_religion_cosmopolitan_syncretic_synergy_vassal_decision = {
		is_high_prio = yes
		ai_check_interval = 12 #check once a year

		potential = {
			independent = no
			liege = {
				NOT = { religion = prev }
				has_syncretic_trigger = yes
			}
			NOR = {
				trait = zealous
				trait = sympathy_christendom
				trait = sympathy_islam
				trait = sympathy_judaism
				trait = sympathy_pagans
				trait = sympathy_zoroastrianism
				trait = sympathy_indian
			}
		}
		effect = {
			if = {
				limit = {
					liege = { religion_group = christian }
				}
				add_trait = sympathy_christendom
			}
			else_if = {
				limit = {
					liege = { religion_group = muslim }
				}
				add_trait = sympathy_islam
			}
			else_if = {
				limit = {
					liege = { religion_group = jewish_group }
				}
				add_trait = sympathy_judaism
			}
			else_if = {
				limit = {
					liege = { religion_group = pagan_group }
				}
				add_trait = sympathy_pagans
			}
			else_if = {
				limit = {
					liege = { religion_group = zoroastrian_group }
				}
				add_trait = sympathy_zoroastrianism
			}
			else_if = {
				limit = {
					liege = { religion_group = indian_group }
				}
				add_trait = sympathy_indian
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.2
			}
			modifier = {
				factor = 2
				trait = cynical
			}
		}
	}

	RR_charity_decision = {
		is_high_prio = yes
		ai_check_interval = 6 #check twice a year

		potential = {
			OR = {
				religion = waldensian
				religion = fraticelli
                has_religion_feature = RR_religion_charity
			}
		}
		allow = {
			wealth = 500
		}
		effect = {
			wealth = -500
			piety = 250
			if = {
				limit = { trait = greedy }
				random = {
					chance = 15
					remove_trait = greedy
				}
			}
			else_if = {
				limit = { NOT = { trait = charitable } }
				random = {
					chance = 15
					add_trait = charitable
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5
				NOT = { wealth = 600 }
			}
			modifier = {
				factor = 0.5
				NOT = { wealth = 800 }
			}
			modifier = {
				factor = 0.5
				NOT = { wealth = 1000 }
			}
			modifier = {
				factor = 0.5
				NOT = { wealth = 1200 }
			}
			modifier = {
				factor = 0.5
				NOT = { wealth = 1600 }
			}
			modifier = {
				factor = 0.5
				NOT = { wealth = 2000 }
			}
			modifier = {
				factor = 10
				trait = charitable
			}
			modifier = {
				factor = 0.1
				trait = greedy
			}
		}
	}

}
