# Targetted decisions are possible vs _all_ other characters and are shown in the Diplomacy View, not the Intrigue View. The taker is in the FROM scope.
#
# filter = [self/court/home_court/vassals/sub_realm/realm/dynasty/all] ('self' MUST be set for decisions targetting only the taker, the other filter types can be set to lessen CPU load)
# ai_target_filter = [self/court/home_court/vassals/sub_realm/realm/dynasty/all] (which characters for which the AI evaluates the decision.)
#	court: all characters in the AI's host court, including prisoners, and characters currently away (wards, prisoners, etc)
#	home_court: all characters in the AI's home court, including prisoners, and characters currently away (wards, prisoners, etc)
#	vassals: direct vassal rulers of the AI's employer
#	sub_realm: all characters below the AI's employer
#	realm: all characters in the same top realm as the AI
#	dynasty: all members of the same dynasty
#	rivals: your rivals plus any character you have an opinion modifier with 'crime = yes' set (the same set of characters the 'is_foe' trigger evaluates)
#	all: all living characters (Avoid if possible. VERY CPU-HEAVY!)
#

targetted_decisions = {
	adopt_child = {
		# Pre-triggers
		ai = no					# AI cannot take this decision
		only_playable = yes			# Count-tier or higher, or Partician

		ai_target_filter = none			# AI can consider no characters
##		filter = all				# Player can consider all characters
##		filter = court				# Player can consider characters in host court
##		filter = home_court			# Player can consider characters in home court
		filter = sub_realm			# Player can consider subordinate characters

		from_potential = {			# IF TRUE: Player/Taker
			OR = {				# (redundant with [only_playable = yes])
				higher_tier_than = BARON
				is_patrician = yes
			}
			NOT = ( 
			  OR = {
				trait = in_hiding
				has_character_modifier = in_seclusion
			  }
			}
		}
		potential = {				# IF TRUE: AI/Target
			NOT = { FROM = { is_parent_of = ROOT } }		# Can't adopt your own child
			NOT = { FROM = { is_grandparent_of = ROOT } }	# or grandchild
			NOT = { age = 16 }
			NOT = ( 
			  OR = {
				trait = in_hiding
				has_character_modifier = in_seclusion
			  }
			}

		}
		allow = {					# IF TRUE: Allow
			FROM = {				# Player/Taker
				could_be_parent_of = ROOT
				treasury = 100
				scaled_wealth = 1.0
				OR = {
					AND = {
						religion_group = christian
						prestige = 50
					}
					prestige = 100
				}

			}
		}
		effect = {
			# The adoption costs FROM wealth and prestige, gives piety
			FROM = {
				wealth = -100
				scaled_wealth = -1.0
				if = { limit = { religion_group = christian }
					prestige = -50
					piety = 100
				}
				else
				{
					prestige = -100
					piety = 50
				}
			}
			# Father of ROOT gains wealth and piety, loses prestige
			FATHER = {
				wealth = 100
				piety = 100
				prestige = -100
			}
			# Reset parentage and dynasty of ROOT
			if = { limit = { FROM = { is_female = no } }
				set_real_father = 0
				set_father = FROM
				set_mother = 0			# In case FROM={SPOUSE} is dead/too young
				FROM = { 
					SPOUSE = { 
						if = { limit = { could_be_parent_of = ROOT }
							ROOT = { set_mother = PREV }
						}
					} 
				}
			}
			else
			{
				set_real_father = 0
				set_father = 0			# In case FROM={SPOUSE} is dead/too young
				FROM = { 
					SPOUSE = { 
						if = { limit = { could_be_parent_of = ROOT }
							ROOT = { set_father = PREV }
						}
					} 
				}
				set_mother = FROM
			}
			dynasty = FROM
			hidden_tooltip = {
				remove_trait = bastard
				remove_trait = legit_bastard
			}
			recalc_succession = yes
			# Move ROOT to court of FROM; If in FROM's prison, release
			move_character = FROM
			if = {
				limit = {
					prisoner = yes
					host = { character = FROM }
				}
				imprison = no
			}
		}
	}

	adopt_adult = {
		# Pre-triggers
		ai = no					# AI cannot take this decision
		only_playable = yes			# Count-tier or higher, or Partician

		ai_target_filter = none			# AI can consider no characters
##		filter = all				# Player can consider all characters
##		filter = court				# Player can consider characters in host court
##		filter = home_court			# Player can consider characters in home court
		filter = sub_realm			# Player can consider subordinate characters

		from_potential = {			# IF TRUE: Player/Taker
			OR = {				# (redundant with [only_playable = yes])
				higher_tier_than = BARON
				is_patrician = yes
			}
			NOT = ( 
			  OR = {
				trait = in_hiding
				has_character_modifier = in_seclusion
			  }
			}
		}
		potential = {				# IF TRUE: AI/Target
			NOT = { FROM = { is_parent_of = ROOT } }		# Can't adopt your own child
			NOT = { FROM = { is_grandparent_of = ROOT } }	# or grandchild
			age = 16
			NOT = ( 
			  OR = {
				trait = in_hiding
				has_character_modifier = in_seclusion
			  }
			}

		}
		allow = {					# IF TRUE: Allow
			FROM = {				# Player/Taker
				could_be_parent_of = ROOT
				scaled_wealth = 10.0
				OR = {
					AND = {
						religion_group = christian
						prestige = 200
						piety = 50
					}
					prestige = 300
					piety = 70
				}

			}
		}
		effect = {
			# The adoption costs FROM wealth and prestige and piety
			FROM = {
				scaled_wealth = -10.0
				if = { limit = { religion_group = christian }
					prestige = -200
					piety = -50
				}
				else
				{
					prestige = -300
					piety = -70
				}
			}
			# Reset parentage and dynasty of ROOT
			if = { limit = { FROM = { is_female = no } }
				set_real_father = 0
				set_father = FROM
#				set_mother = 0			# In case FROM={SPOUSE} is dead/too young
##				FROM = { 
##					SPOUSE = { 
##						if = { limit = { could_be_parent_of = ROOT }
##							ROOT = { set_mother = PREV }
##						}
##					} 
##				}
			}
			else
			{
#				set_real_father = 0
#				set_father = 0			# In case FROM={SPOUSE} is dead/too young
##				FROM = { 
##					SPOUSE = { 
##						if = { limit = { could_be_parent_of = ROOT }
##							ROOT = { set_father = PREV }
##						}
##					} 
##				}
				set_mother = FROM
			}
			dynasty = FROM
			hidden_tooltip = {
				remove_trait = bastard
				remove_trait = legit_bastard
			}
			recalc_succession = yes
##			# Move ROOT to court of FROM
##			move_character = FROM
			# If in FROM's prison, release
			if = {
				limit = {
					prisoner = yes
					host = { character = FROM }
				}
				imprison = no
			}
		}
	}
}