﻿# form_new_cali_decision = {
	#	picture = {
	#	reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	#}
	#	decision_group_type = major
	#	ai_check_interval = 8
	#	desc = form_new_cali_decision_desc
	#	selection_tooltip = form_new_cali_decision_effect_tooltip
	#
	#	is_shown = {
	#		is_ruler = yes
	#		is_landed = yes
	#		NOT = {
	#			is_target_in_global_variable_list = {
	#				name = unavailable_unique_decisions
	#				target = flag:form_new_cali_decision
	#			}
	#		}
	#		NOT = { faith = faith:cetic }
	#		any_held_title = {
	#			tier = tier_county
	#			empire = title:e_california
	#		}
	#	}
	#
	#	is_valid = {
	#	
	#		highest_held_title_tier <= tier_kingdom
	#
	#		has_title = title:k_andreas
	#		has_title = title:k_the_valley
	#		has_title = title:k_socal
	#	}
	#
	#	effect = {
	#		save_scope_as = new_cali_former
	#		form_new_cali_decision_effects = yes
	#		give_nickname = nick_the_bear
	#
	#
	#		#Events
	#		
	#		trigger_event = ate_form.00014
	#	
	#
	#		#Can only happen once
	#		add_to_global_variable_list = {
	#			name = unavailable_unique_decisions
	#			target = flag:form_new_cali_decision
	#		}
	#		set_global_variable = {
	#			name = form_new_cali_decision
	#			value = scope:new_cali_former
	#		}
	#	}
	#
	#	cost = { 
	#		prestige = { value = 1000 }
	#	}
	#
	#	ai_potential = {
	#		# Only for the AI if independent ruler
	#		is_independent_ruler = yes
	#	}
	#
	#	ai_will_do = {
	#		base = 100
	#	}
#}


## South America

restore_up_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { has_doctrine = tenet_the_hand_of_god }
				}
				desc = restore_up_decision_desc_heroic
			}
			triggered_desc = {
				trigger = {
					faith = { has_doctrine = tenet_las_veinte_verdades }
				}
				desc = restore_up_decision_desc_peronist
			}
			desc = restore_up_decision_desc
		}
	}
	selection_tooltip = restore_up_decision_tooltip
	decision_group_type = major

	ai_check_interval = 8

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restore_up_decision
			}
		}
		NOT = { government_has_flag = government_is_tribal }
		OR = {
			faith = { # Your faith must have either La Mano de Dios, Las Veinte Verdades, Cultos de los Heroes, or Cantos de los Pueblos
				OR = {
					religion = religion:platinean_religion
					religion = religion:pampeano_religion
					has_doctrine = tenet_las_veinte_verdades
					has_doctrine = tenet_the_hand_of_god
					has_doctrine = special_doctrine_cultos_de_los_heroes_astronomer
					has_doctrine = special_doctrine_cultos_de_los_heroes_platinean
					has_doctrine = special_doctrine_cultos_de_los_heroes_pampeano
					has_doctrine = special_doctrine_cantos_de_los_pueblos
				}
			}
		}
	}

	is_valid = {
		prestige_level >= max_prestige_level
		custom_tooltip = {
			text = form_up_decision_tt
			any_county_in_region = {
				region = custom_laplata
				percent >= ate_formable_target_percent_decimal_value
				holder.top_liege = root
			}
		}

		OR = {
			AND = { # Have Hand of God AND be a chosen competitor...
				custom_description = {
					text = you_have_been_chosen_tt
					has_character_flag = flag_chosen_competitor
				}
				faith = {
					has_doctrine = tenet_the_hand_of_god
				}
			}
			AND = {
				faith = {
					NOT = {
						has_doctrine = tenet_the_hand_of_god
					}
					OR = {
						religion = religion:platinean_religion
						religion = religion:pampeano_religion 
						has_doctrine = tenet_las_veinte_verdades
						custom_description = {
							text = has_cultos_de_los_heroes_tt
							OR = {
								has_doctrine = special_doctrine_cultos_de_los_heroes_astronomer
								has_doctrine = special_doctrine_cultos_de_los_heroes_platinean
								has_doctrine = special_doctrine_cultos_de_los_heroes_pampeano
							}
						}
						has_doctrine = special_doctrine_cantos_de_los_pueblos
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
	}

	effect = {
		custom_tooltip = restore_up_decision_effect_tooltip
		save_scope_as = la_plata_former
		hidden_effect = {
			restore_up_decision_effects = yes
		}
		trigger_event = {
			id = ate_form.0005
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restore_up_decision
			}
			set_global_variable = {
				name = restore_up_decision
				value = root
			}
		}
		add_prestige = 1000
		add_legitimacy = 500
		if = {
			limit = { has_dlc_feature = legends }
			create_legend_seed = {
				type = legitimizing
				quality = illustrious
				chronicle = new_title
				properties = {
					title = title:e_united_provinces
					founder = root
				}
			}
		}	
	}
	cost = { 
		gold = { value = 300 } 
		prestige = { value = 2000 }
	}
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

form_rio_grande_do_sul_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = form_rio_grande_do_sul_decision_desc

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_rio_grande_do_sul_decision
			}
		}
		# Must be in the vague region.
		any_held_title = {
			tier = tier_county
			title_province = { geographical_region = custom_rio_grande_do_sul }
		}
		highest_held_title_tier <= tier_kingdom
	}
	is_valid = {

			has_title = title:k_piratini
			has_title = title:k_planalto
			has_title = title:k_campanha
			custom_tooltip = {
				text = form_rio_grande_do_sul_decision_tt
				any_county_in_region = {
					region = custom_rio_grande_do_sul
					percent >= ate_formable_target_percent_decimal_value
					holder.top_liege = root
				}
			}
	}

	effect = {
		save_scope_as = rio_grande_do_sul_unifier
		hidden_effect = {
			form_rio_grande_do_sul_decision_effects = yes
		}
		give_nickname = nick_the_restorer 	

		#Events
		
		trigger_event = ate_form.0017

		
		

	

		#Can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:form_rio_grande_do_sul_decision
		}
		set_global_variable = {
			name = form_rio_grande_do_sul_decision
			value = scope:rio_grande_do_sul_unifier
		}
	}

	cost = { 
		gold = { value = 300 } 
		prestige = { value = 1000 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}

form_bolivia_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = form_bolivia_decision_desc
	selection_tooltip = form_bolivia_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		highest_held_title_tier <= tier_kingdom
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_bolivia_decision
			}
		}
		# Must be in the vague region.
		any_held_title = {
			tier = tier_county
			title_province = { geographical_region = custom_bolivia_formable }
		}
		
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_range
			government_has_flag = government_is_high_republic
			government_has_flag = government_is_tribal
			government_has_flag = government_is_clan
			government_has_flag = government_is_state_bureaucracy
		}
	}

	is_valid = {

		has_title = title:k_collao
		has_title = title:k_grigota
		
		custom_tooltip = {
			text = form_bolivia_decision_tt
			any_county_in_region = {
				region = custom_bolivia_formable
				percent >= ate_formable_target_percent_decimal_value
				holder.top_liege = root
			}
		}
	}

	effect = {
		save_scope_as = bolivia_former
		hidden_effect = {
			form_bolivia_decision_effects = yes
		}
		give_nickname = nick_the_great
		add_prestige = 1000
		add_legitimacy = 500
		if = {
			limit = { has_dlc_feature = legends }
			create_legend_seed = {
				type = legitimizing
				quality = illustrious
				chronicle = new_title
				properties = {
					title = title:e_bolivia
					founder = root
				}
			}
		}	
		#Events
		
		trigger_event = ate_form.0029
	

		#Can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:form_bolivia_decision
		}

		set_global_variable = {
			name = form_bolivia_decision
			value = scope:bolivia_former
		}
	}

	cost = { 
		gold = { value = 300 } 
		prestige = { value = 1000 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}

form_palmares_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = form_palmares_decision_desc

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_palmares_decision
			}
		}

		any_held_title = {
			tier = tier_county
			title_province = { geographical_region = world_brazil_nordeste }
			}
		highest_held_title_tier <= tier_kingdom
	}
	
	is_valid = {
			religion = religion:afro_diasporic_religion
			prestige_level  >= 3
			piety_level >= 4
			has_title = title:d_alagoas
			OR = {
				AND = {
					has_title = title:d_br_30_recife
					has_title = title:d_br_28_aracaju
				}
				AND = {
					has_title = title:d_princesa
					has_title = title:d_br_28_aracaju
				}
				AND = {
					has_title = title:d_br_30_recife
					has_title = title:d_princesa
				}
			}
			#custom_tooltip = {
			#	text = form_palmares_decision_tt
			#	any_county_in_region = {
			#		region = world_brazil_nordeste
			#		percent >= ate_formable_target_percent_decimal_value
			#		holder.top_liege = root
			#	}
			#}
	}

	effect = {
		save_scope_as = palmares_unifier
		hidden_effect = { form_palmares_decision_effects = yes }
		give_nickname = nick_the_ganga_zumba
	
		trigger_event = ate_form.0036

		#Can only happen once
		add_to_global_variable_list = {
		name = unavailable_unique_decisions
		target = flag:form_palmares_decision
		}
		
		set_global_variable = {
		name = form_palmares_decision
		value = scope:palmares_unifier
		}
	}

	cost = { 
	gold = { value = 300 } 
	piety = { value = 350 }
	}

	ai_potential = {
	# Only for the AI if independent ruler
	is_independent_ruler = yes
	}

	ai_will_do = {
	base = 100
	}
}

#form_paulistania_decision = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
#	}
#	decision_group_type = major
#	ai_check_interval = 8
#	desc = form_paulistania_decision_desc
#	selection_tooltip = form_paulistania_decision_effect_tooltip
#
#	is_shown = {
#		is_ruler = yes
#		is_landed = yes
#		is_independent_ruler = yes
#		highest_held_title_tier <= tier_kingdom
#		NOT = {
#		is_target_in_global_variable_list = {
#				name = unavailable_unique_decisions
#				target = flag:form_paulistania_decision
#			}
#		}
#		title:e_paulistania = {
#			is_title_created = no
#		}
#		# Must be in the vague region.
#		any_held_title = {
#			tier = tier_county
#			title_province = { geographical_region = custom_paulistania_formable }
#		}
#		OR = {
#			culture = {
#				OR = {
#					has_cultural_pillar = heritage_paulistanico
#					has_cultural_pillar = language_paulistano
#					has_cultural_pillar = language_caipira
#					any_parent_culture_or_above = {
#						OR = {
#							has_cultural_pillar = heritage_paulistanico
#							has_cultural_pillar = language_paulistano
#							has_cultural_pillar = language_caipira
#						}
#					}
#				}
#			}
#		}
#	}
#
#	is_valid = {
#
#		has_title = title:k_sao_paulo
#		has_title = title:k_tiete
#		OR = {
#			completely_controls = title:k_triangle
#			completely_controls = title:k_sudiminas
#			completely_controls = title:k_parana
#			completely_controls = title:k_mato_grosso_do_sul
#			
#			has_title = title:k_triangle
#			has_title = title:k_sudiminas
#			has_title = title:k_parana
#			has_title = title:k_mato_grosso_do_sul
#		}
#		
#		OR = {
#			culture = {
#				OR = {
#					has_cultural_pillar = heritage_paulistanico
#					has_cultural_pillar = language_paulistano
#					has_cultural_pillar = language_caipira
#					any_parent_culture_or_above = {
#						OR = {
#							has_cultural_pillar = heritage_paulistanico
#							has_cultural_pillar = language_paulistano
#							has_cultural_pillar = language_caipira
#						}
#					}
#				}
#			}
#		}
#		
#		custom_tooltip = {
#			text = form_paulistania_decision_tt
#			any_county_in_region = {
#				region = custom_paulistania_formable
#				percent >= ate_formable_target_percent_decimal_value
#				holder.top_liege = root
#			}
#		}
#	}
#
#	effect = {
#		save_scope_as = paulistania_former
#		hidden_effect = {
#			#form_paulistania_decision_effects = yes
#			
#			create_title_and_vassal_change = {
#				type = created
#				save_scope_as = title_change
#				add_claim_on_loss = no
#			}
#			title:e_paulistania = {
#				change_title_holder = {
#					holder = scope:paulistania_former
#					change = scope:title_change
#				}
#			}
#			resolve_title_and_vassal_change = scope:title_change
#			
#
#			if = {
#				limit = {
#					AND = {
#						exists = title:e_paulistania.holder
#						
#					} 
#				}
#				title:k_sao_paulo = {
#					set_de_jure_liege_title = title:e_paulistania
#				}
#				title:k_tiete = {
#					set_de_jure_liege_title = title:e_paulistania
#				}
#			}
#			
#			if = {
#				limit = {
#					scope:paulistania_former = {
#						OR = {
#							completely_controls = title:k_parana
#							has_title = title:k_parana
#						}
#					}
#				}
#				title:k_parana = {
#					set_de_jure_liege_title = title:e_paulistania
#				}
#			}
#			if = {
#				limit = {
#					scope:paulistania_former = {
#						OR = {
#							completely_controls = title:k_mato_grosso_do_sul
#							has_title = title:k_mato_grosso_do_sul
#						}
#					}
#				}
#				title:k_mato_grosso_do_sul = {
#					set_de_jure_liege_title = title:e_paulistania
#				}
#			}
#			if = {
#				limit = {
#					scope:paulistania_former = {
#						OR = {
#							completely_controls = title:k_triangle
#							has_title = title:k_triangle
#						}
#					}
#				}
#				title:k_triangle = {
#					set_de_jure_liege_title = title:e_paulistania
#				}
#			}
#			if = {
#				limit = {
#					scope:paulistania_former = {
#						OR = {
#							completely_controls = title:k_sudiminas
#							has_title = title:k_sudiminas
#						}
#					}
#				}
#				title:k_sudiminas = {
#					set_de_jure_liege_title = title:e_paulistania
#				}
#			}
#			
#		}
#		give_nickname = nick_the_bandeirante
#		add_prestige = 1000
#		add_legitimacy = 500
#		if = {
#			limit = { has_dlc_feature = legends }
#			create_legend_seed = {
#				type = legitimizing
#				quality = illustrious
#				chronicle = new_title
#				properties = {
#					title = title:e_paulistania
#					founder = root
#				}
#			}
#		}	
#		#Events
#		
#		trigger_event = ate_form.0039
#	
#
#		#Can only happen once
#		add_to_global_variable_list = {
#			name = unavailable_unique_decisions
#			target = flag:form_paulistania_decision
#		}
#
#		set_global_variable = {
#			name = form_paulistania_decision
#			value = scope:paulistania_former
#		}
#	}
#
#	cost = { 
#		gold = { value = 300 } 
#		prestige = { value = 1000 }
#	}
#
#	ai_potential = {
#		# Only for the AI if independent ruler
#		is_independent_ruler = yes
#	}
#
#	ai_will_do = {
#		base = 100
#	}
#}

integrate_bahia_into_nordeste_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_bahia_into_nordeste_decision_desc
	#selection_tooltip = integrate_bahia_into_nordeste_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		OR = {
			has_title = title:e_nordeste
			has_title = title:e_bahia
		}
	}

	is_valid = {
		has_title = title:e_nordeste
		has_title = title:e_bahia
		is_at_war = no
	}

	effect = {
		title:e_bahia = {
			every_direct_de_jure_vassal_title = {
				set_de_jure_liege_title = title:e_nordeste
			}
		}
		destroy_title = title:e_bahia
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}


integrate_paulistania_into_sudeste_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_paulistania_into_sudeste_decision_desc
	#selection_tooltip = integrate_paulistania_into_sudeste_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		OR = {
			has_title = title:e_sudeste
			has_title = title:e_paulistania
		}
	}

	is_valid = {
		has_title = title:e_sudeste
		has_title = title:e_paulistania
		is_at_war = no
	}

	effect = {
		title:e_paulistania = {
			every_direct_de_jure_vassal_title = {
				set_de_jure_liege_title = title:e_sudeste
			}
		}
		destroy_title = title:e_paulistania
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}


integrate_gerais_into_sudeste_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_gerais_into_sudeste_decision_desc
	#selection_tooltip = integrate_gerais_into_sudeste_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		OR = {
			has_title = title:e_sudeste
			has_title = title:e_gerais
		}
	}

	is_valid = {
		has_title = title:e_sudeste
		has_title = title:e_gerais
		is_at_war = no
	}

	effect = {
		title:e_gerais = {
			every_direct_de_jure_vassal_title = {
				set_de_jure_liege_title = title:e_sudeste
			}
		}
		destroy_title = title:e_gerais
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}


integrate_cerrado_into_brazil_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_cerrado_into_brazil_decision_desc
	#selection_tooltip = integrate_cerrado_into_brazil_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		has_title = title:e_brazil
		OR = {
			has_title = title:e_cerrado
			
			has_title = title:k_mato_grosso_do_sul
			any_vassal = {
				has_title = title:k_mato_grosso_do_sul
			}
			has_title = title:k_mato_grosso
			any_vassal = {
				has_title = title:k_mato_grosso
			}
			has_title = title:k_goias
			any_vassal = {
				has_title = title:k_goias
			}
			has_title = title:k_tocantins
			any_vassal = {
				has_title = title:k_tocantins
			}
		}
	}

	is_valid = {
		has_title = title:e_brazil
		has_title = title:e_cerrado
		custom_tooltip = {
			text = integrate_cerrado_decision_tt
			title:e_cerrado = {
				any_de_jure_county = {
					percent >= ate_formable_target_percent_decimal_value
					OR = {
						holder.top_liege = root
						holder = root
					}
				}
			}
		}
		is_at_war = no
	}

	effect = {
		title:e_brazil = {
			set_variable = integrated_cerrado
		}
		title:e_cerrado = {
			every_direct_de_jure_vassal_title = {
				set_de_jure_liege_title = title:e_brazil
			}
		}
		destroy_title = title:e_cerrado
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}


integrate_o_sul_into_brazil_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_o_sul_into_brazil_decision_desc
	#selection_tooltip = integrate_o_sul_into_brazil_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		has_title = title:e_brazil
		OR = {
			has_title = title:e_o_sul
			
			has_title = title:k_parana
			any_vassal = {
				has_title = title:k_parana
			}
			has_title = title:k_santa_catarina
			any_vassal = {
				has_title = title:k_santa_catarina
			}
			has_title = title:k_rio_grande_do_sul
			any_vassal = {
				has_title = title:k_rio_grande_do_sul
			}
		}
	}

	is_valid = {
		has_title = title:e_brazil
		has_title = title:e_o_sul
		custom_tooltip = {
			text = integrate_o_sul_decision_tt
			title:e_o_sul = {
				any_de_jure_county_holder = {
					percent >= ate_formable_target_percent_decimal_value
					top_liege = root
				}
			}
		}
		is_at_war = no
	}

	effect = {
		title:e_brazil = {
			set_variable = integrated_o_sul
		}
		title:e_o_sul = {
			every_direct_de_jure_vassal_title = {
				set_de_jure_liege_title = title:e_brazil
			}
		}
		destroy_title = title:e_o_sul
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}


integrate_northern_territories_into_brazil_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_northern_territories_into_brazil_decision_desc
	#selection_tooltip = integrate_northern_territories_into_brazil_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		has_title = title:e_brazil
		OR = {
			has_title = title:k_amazonas
			has_title = title:k_oyapock
			has_title = title:k_roraima
			any_vassal = {
				has_title = title:k_amazonas
			}
			any_vassal = {
				has_title = title:k_oyapock
			}
			any_vassal = {
				has_title = title:k_roraima
			}
		}
	}

	is_valid = {
		has_title = title:e_brazil
		OR = {
			has_title = title:k_amazonas
			any_vassal = {
				has_title = title:k_amazonas
			}
		}
		OR = {
			has_title = title:k_oyapock
			any_vassal = {
				has_title = title:k_oyapock
			}
		}
		completely_controls = title:d_amapa
		completely_controls = title:d_oyapock
		OR = {
			has_title = title:k_roraima
			any_vassal = {
				has_title = title:k_roraima
			}
		}
		completely_controls = title:k_roraima
		is_at_war = no
	}

	effect = {
		title:e_brazil = {
			set_variable = integrated_northern_territories
		}
		title:k_amazonas = {
			set_de_jure_liege_title = title:e_brazil
		}
		title:k_oyapock = {
			set_de_jure_liege_title = title:e_brazil
		}
		if = {
			limit = {
				NOT = {
					completely_controls = title:k_oyapock
				}
			}
			title:d_cayenne = { set_de_jure_liege_title = title:d_suriname.de_jure_liege }
		}
		
		title:k_roraima = {
			set_de_jure_liege_title = title:e_brazil
		}
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}


integrate_amazonia_into_brazil_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 8
	desc = integrate_amazonia_into_brazil_decision_desc
	#selection_tooltip = integrate_amazonia_into_brazil_decision_effect_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		has_title = title:e_brazil
		OR = {
			has_title = title:e_amazonia
			
			has_title = title:k_amazonas
			any_vassal = {
				has_title = title:k_amazonas
			}
			
			has_title = title:k_acre
			any_vassal = {
				has_title = title:k_acre
			}
			
			has_title = title:k_rio_negro_e_solimoes
			any_vassal = {
				has_title = title:k_rio_negro_e_solimoes
			}
			
			has_title = title:k_rondonia
			any_vassal = {
				has_title = title:k_rondonia
			}
		}
	}

	is_valid = {
		has_title = title:e_brazil
		has_title = title:e_amazonia
		custom_tooltip = {
			text = integrate_amazonia_decision_tt
			title:e_amazonia = {
				any_de_jure_county_holder = {
					percent >= ate_formable_target_percent_decimal_value
					top_liege = root
				}
			}
		}
		is_at_war = no
	}

	effect = {
		title:e_brazil = {
			set_variable = integrated_amazonia
		}
		title:e_amazonia = {
			every_direct_de_jure_vassal_title = {
				set_de_jure_liege_title = title:e_brazil
			}
		}
		destroy_title = title:e_amazonia
	}

	cost = { 
		prestige = { value = 100 }
	}

	ai_potential = {
		# Only for the AI if independent ruler
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}