BRA_industrial_decisions = {
	BRA_federal_investment_in_rural_state = {
		icon = GFX_decision_gre_paying_ifc_debt
	
		allowed = {
			original_tag = BRA
		}
	
		#available = {
		#	has_completed_focus = BRA_financial_stimulation
		#}
		
		visible = {
			has_completed_focus = BRA_financial_stimulation
			#any_core_state = {}
		}
		state_target = yes
	    target_trigger = {
	        FROM = {
	           	is_fully_controlled_by = ROOT
	           	has_dynamic_modifier = { modifier = BRA_neglected_state_dynamic_modifier }
	           	NOT = {
	           		state = 961
	           		state = 962
	           		state = 963
	           		state = 964
	           		state = 965
	           		state = 966
	           		state = 967
	           		state = 968
	           	}
	        }
	    }
	    on_map_mode = map_and_decisions_view 
		cost = 35
		
		fire_only_once = yes
		days_remove = 60
		#cancel_trigger = {
		#	NOT = { is_fully_controlled_by = ROOT }
		#}

		modifier = {
			political_power_factor = -0.1
			production_speed_buildings_factor = -0.05
			consumer_goods_factor = 0.05
		}
		
		remove_effect = {
			FROM = {	
				custom_effect_tooltip = BRA_federal_investment_in_rural_state_tt
				effect_tooltip = {
					add_to_variable = {
						BRA_state_development_production_speed_new = 0.15
						tooltip = MODIFIER_STATE_PRODUCTION_SPEED_BUILDINGS_FACTOR_tt
					}
					add_to_variable = {
						BRA_state_development_local_factories_new = 0.15
						tooltip = local_factories_tt
					}
					add_to_variable = {
						BRA_state_development_local_building_slots_factor_new = 0.2
						tooltip = MODIFIER_LOCAL_BUILDING_SLOTS_FACTOR_tt
					}
					add_to_variable = {
						BRA_state_development_state_resources_factor_new = 0.2
						tooltip = MODIFIER_STATE_RESOURCES_FACTOR_tt
					}
				}
				hidden_effect = {
					# Saving the variables as removing the original dm breaks them
					set_variable = { BRA_state_development_production_speed_new = BRA_state_development_production_speed }
					set_variable = { BRA_state_development_local_factories_new = BRA_state_development_local_factories }
					set_variable = { BRA_state_development_local_building_slots_factor_new = BRA_state_development_local_building_slots_factor }
					set_variable = { BRA_state_development_state_resources_factor_new = BRA_state_development_state_resources_factor }
					# Adding value here as the values get messed up otherwise -_-
					add_to_variable = {
						BRA_state_development_production_speed_new = 0.15
						tooltip = MODIFIER_STATE_PRODUCTION_SPEED_BUILDINGS_FACTOR_tt
					}
					add_to_variable = {
						BRA_state_development_local_factories_new = 0.15
						tooltip = local_factories_tt
					}
					add_to_variable = {
						BRA_state_development_local_building_slots_factor_new = 0.2
						tooltip = MODIFIER_LOCAL_BUILDING_SLOTS_FACTOR_tt
					}
					add_to_variable = {
						BRA_state_development_state_resources_factor_new = 0.2
						tooltip = MODIFIER_STATE_RESOURCES_FACTOR_tt
					}
					remove_dynamic_modifier = {
						modifier = BRA_neglected_state_dynamic_modifier
					}
					# Restoring the old values for the new modifier + the new bonus
					set_variable = { BRA_state_development_production_speed = BRA_state_development_production_speed_new }
					set_variable = { BRA_state_development_local_factories = BRA_state_development_local_factories_new }
					set_variable = { BRA_state_development_local_building_slots_factor = BRA_state_development_local_building_slots_factor_new }
					set_variable = { BRA_state_development_state_resources_factor = BRA_state_development_state_resources_factor_new }
					# Ta da
					add_dynamic_modifier = {
						modifier = BRA_growing_state_dynamic_modifier
					}
				}
			}
		}
	
		ai_will_do = {
		}
	}
}

BRA_ensure_support_cat = {

	BRA_integralist_support = {
		icon = GFX_decision_BRA_integralism
		allowed = {
			original_tag = BRA
		}
		available = {
			NOT = {
				has_country_flag = BRA_gaining_support_in_progress 
			}
		}
		ai_will_do = {
			base = 10
			modifier = {
				factor = 0.5
				has_government = fascism
			}
			modifier = {
				factor = 10
				fascism < 0.51
			}
		}
		visible = {
			has_completed_focus = BRA_work_with_the_integralists
			NOT = {
				has_completed_focus = BRA_estado_novo
			}
		}
		state_target = yes
		target_trigger = {
		    FROM = {
		    	is_fully_controlled_by = ROOT
		    	is_core_of = ROOT
		       	NOT = {
		       		has_state_flag = BRA_gained_support
		       	}
		       	OR = {
		       		has_state_category = town
		       		has_state_category = large_town
		       		has_state_category = city
		       		has_state_category = large_city
		       		has_state_category = megalopolis
		       		has_state_category = metropolis
		       	} 
		    }
		}
		on_map_mode = map_and_decisions_view
		cost = 20
		
		fire_only_once = yes
		days_remove = 10
		complete_effect = {
			set_country_flag = BRA_gaining_support_in_progress
		}
		remove_effect = {
			FROM = {
				set_state_flag = BRA_gained_support
			}
			random_list = {
				# Bad march
				35 = {
					country_event = { id = JUNO_brazil_events.10 days = 1 }
					effect_tooltip = {
						add_popularity = { ideology = fascism popularity = 0.01 }
					}
				}
				# Average march
				50 = {
					country_event = { id = JUNO_brazil_events.11 days = 1 }
					effect_tooltip = {
						add_popularity = { ideology = fascism popularity = 0.03 }
					}
				}
				# Good march
				15 = {
					country_event = { id = JUNO_brazil_events.12 days = 1 }
					effect_tooltip = {
						add_popularity = { ideology = fascism popularity = 0.05 }
					}
				}
			}
		}
	}

	BRA_recruit_green_shirts = {
		icon = GFX_decision_eng_blackshirt_march
		allowed = {
			original_tag = BRA
		}
		available = {
			FROM = {
				has_state_flag = BRA_gained_support
			} 
		}
		
		visible = {
			has_completed_focus = BRA_anaue
		}
		state_target = yes
		target_trigger = {
		    FROM = {
		    	is_fully_controlled_by = ROOT
		    	is_core_of = ROOT
		       	OR = {
		       		has_state_category = town
		       		has_state_category = large_town
		       		has_state_category = city
		       		has_state_category = large_city
		       		has_state_category = megalopolis
		       		has_state_category = metropolis
		       	} 
		    }
		}
		on_map_mode = map_and_decisions_view
		cost = 20
		ai_will_do = {
			base = 20
			modifier = {
				factor = 10
				fascism < 0.51
			}
		}
		fire_only_once = yes
		days_remove = 10
		complete_effect = {
			FROM = {			
				set_state_flag = BRA_recruitment_in_progress
			}
		}
		remove_effect = {
			FROM = {
				clr_state_flag = BRA_recruitment_in_progress
			}		
			#effect_tooltip = {
			#	set_temp_variable = { BRA_new_militia_cap_for_tooltip = BRA_green_shirt_division_cap }
			#	add_to_temp_variable = { BRA_new_militia_cap_for_tooltip = 1 }
			#	set_division_template_cap = { 
			#		division_template = "Integralist Militia" 
			#		division_cap = BRA_new_militia_cap_for_tooltip   
			#	}
			#}

			#hidden_effect = {
			#	add_to_variable = { BRA_green_shirt_division_cap = 1 }
			#	clamp_variable = {
			#		var = BRA_green_shirt_division_cap
			#		min = 0 
			#		max = BRA_max_green_shirt_division_cap
			#	}  
			#	set_division_template_cap = { 
			#		division_template = "Integralist Militia" 
			#		division_cap = BRA_green_shirt_division_cap  
			#	}
			#}
			FROM = {
				create_unit = {
					division = "name = \"Integralist Militia\" division_template = \"Integralist Militia\" start_experience_factor = 0.1 start_equipment_factor = 0.7 start_manpower_factor = 0.7"
					owner = ROOT
				}
			}
		}
	}

	BRA_execute_the_cohen_plan = {
		icon = GFX_decision_generic_prepare_civil_war
		allowed = {
			original_tag = BRA
		}	
		available = {
			OR = {
				has_completed_focus = BRA_estado_moderno
				has_completed_focus = BRA_estado_novo
			}
		}
		days_mission_timeout = 100
		activation = {
			has_completed_focus = BRA_cohen_plan
		}
		cancel_trigger = {
		}
		fire_only_once = yes
		is_good = no
		timeout_effect = {
			news_event = {
				id = south_american_news.60
				hours = 1
			}
			retire_country_leader =  yes
			add_stability = -0.05
			#random_list = {
				#50 = {
			random_unit_leader = {
				add_country_leader_role = {
					country_leader = {
						ideology = despotism
						expire = "1965.1.1.1"
					}
					promote_leader = yes
				}
			}
			set_politics = {
				ruling_party = neutrality
				last_election = "1934.3.26"
				election_frequency = 48
				elections_allowed = no
			}
				#}
				#50 = {
				#	set_politics = {
				#		ruling_party = fascism
				#		last_election = "1934.3.26"
				#		election_frequency = 48
				#		elections_allowed = no
				#	}
				#}
			#}		
		}
	}
}

BRA_cangaceiro_decision_cat = {
	BRA_deal_with_the_cangaceiro_dec = {
		icon = GFX_decision_generic_prepare_civil_war
		allowed = {
			original_tag = BRA
		}
		available = {
			NOT = {
				OR = {
					has_country_flag = BRA_anti_cangaceiro_op_in_progress
					has_completed_focus = BRA_sway_the_cangaco
				}
			}
			has_completed_focus = BRA_deal_with_the_cangaceiro
		}
		
		visible = {
			NOT = {
				has_completed_focus = BRA_sway_the_cangaco
			}
		}

		ai_will_do = {
			base = 100
			modifier = {
				factor = 10
				has_stability < 0.4
			}
		}
		state_target = yes
		target_trigger = {
		    FROM = {
		    	is_fully_controlled_by = ROOT
		    	has_dynamic_modifier = {
		    		modifier = BRA_cangaceiro_state
		    	}
		    }
		}
		on_map_mode = map_and_decisions_view
		custom_cost_trigger = {
			command_power > 24.9
		}
		custom_cost_text = BRA_decision_cost_cangaceiro

		fire_only_once = no
		days_remove = 30
		complete_effect = {
			set_country_flag = BRA_anti_cangaceiro_op_in_progress
			add_command_power = -25
		}
		remove_effect = {
			# TODO_JUNO: Add some more stuff here to make it more interesting
			clr_country_flag = BRA_anti_cangaceiro_op_in_progress
			army_experience = 10
			FROM = {
				remove_dynamic_modifier = {
					modifier = BRA_cangaceiro_state
				}
				OWNER = {
					add_days_mission_timeout = {
						mission = BRA_cangaceiro_mission
						days = 50
						#has_active_mission = BRA_cangaceiro_mission
					}
					IF = {
						limit = {
							OWNER = {
								any_owned_state = {
									has_dynamic_modifier = {
										modifier = BRA_cangaceiro_state
									}
								}
							}						
						}
						country_event = {
							id = JUNO_brazil_events.151
							hours = 1
						}
					}
					ELSE = {
						country_event = {
							id = JUNO_brazil_events.152
							hours = 1
						}
					}
				}
			}
		}
	}
	BRA_cangaceiro_mission = {
		icon = GFX_decision_revolt
		allowed = {
			original_tag = BRA
		}	
		available = {
			OR = {
				NOT = {
					any_owned_state = {
						has_dynamic_modifier = {
							modifier = BRA_cangaceiro_state
						}
					}
					has_completed_focus = BRA_sway_the_cangaco
				}
				has_completed_focus = BRA_sway_the_cangaco
			}
		}
		#visible = {
		#	NOT = {
		#		has_completed_focus = BRA_sway_the_cangaco
		#	}
		#}
		days_mission_timeout = 365
		activation = {
			AND = {
				any_state = {
					has_dynamic_modifier = {
						modifier = BRA_cangaceiro_state
					}
				}
				NOT = {
					has_completed_focus = BRA_sway_the_cangaco
				}
			}
		}
		cancel_trigger = {
			937 = { NOT = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}}
			935 = { NOT = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}}
			498 = { NOT = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}}
			936 = { NOT = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}}
			499 = { NOT = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}}
		}
		fire_only_once = no
		is_good = no
		timeout_effect = {
			random_list = {
				30 = {
					modifier = {
						factor = 0
						AND = {
							937 = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}
							935 = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}
							498 = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}
							936 = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}
							499 = { has_dynamic_modifier = { modifier = BRA_cangaceiro_state }}
						}
					}
					set_country_flag = BRA_cangaceiro_spread_flag
					event_option_tooltip = JUNO_brazil_events.150.c
				}
				30 = {
					set_country_flag = BRA_cangaceiro_small_raid_flag
					event_option_tooltip = JUNO_brazil_events.150.a
				}
				40 = {
					set_country_flag = BRA_cangaceiro_big_raid_flag
					event_option_tooltip = JUNO_brazil_events.150.b
				}
			}
			country_event = {
				id = JUNO_brazil_events.150
				hours = 1
			}
		}
	}
}

BRA_good_neighbor_decisions = {
	BRA_washington_accords_mission = {
		icon = GFX_decision_generic_prepare_civil_war
		allowed = {
			original_tag = BRA
		}	
		available = {
			OR = {
				is_in_faction_with = USA
				USA = {
					has_war = no
				}
				any_country = {
					AND = {
						has_war_with = USA
						has_war_with = BRA
					}
				}
			}
		}
		days_mission_timeout = 730
		activation = {
			has_idea = BRA_washington_accords_idea
		}
		cancel_trigger = {
		}
		fire_only_once = yes
		is_good = no
		timeout_effect = {
			country_event = {
				id = JUNO_brazil_events.18
				hours = 1
			}
		}
	}
}

BRA_mercosul_decisions = {
	BRA_invite_to_mercosul = {
		icon = GFX_decision_eng_trade_unions_support
		allowed = {
			original_tag = BRA
		}
		visible = {
			has_completed_focus	= BRA_form_mercosul
		}
		available = {
			has_completed_focus	= BRA_form_mercosul
			FROM = {
				has_opinion = {
					target = ROOT
					value > 24
				}
			}
			NOT = {
				has_war_with = FROM
			}
		}
		on_map_mode = map_and_decisions_view
		target_trigger = {
		    FROM = { 
		    	AND = {
		    		NOT = { 
		    			is_in_faction_with = ROOT
		    			tag = ROOT
		    		}
		    		OR = { 
		    			is_subject = no
		    			is_subject_of = ROOT
		    		}
		    	}
		    	capital_scope = { is_on_continent = south_america }
		    }
		}
		cost = 20
		ai_will_do = {
			base = 35
			modifier = {
				factor = 0
				is_in_faction = yes
			}
		}
		fire_only_once = no
		days_remove = 10
		complete_effect = {

		}
		remove_effect = {
			FROM = {
				country_event = {
					id = JUNO_brazil_events.50
					hours = 1
				}
			}
			custom_effect_tooltip = BRA_invite_to_organization_of_american_states_tt
		}
	}	
}

BRA_amazonian_settlement_cat = {

	BRA_amazonian_settlement_in_state = {

		icon = GFX_decision_generic_construction

		ai_will_do = {
			base = 10
		}

		allowed = {
			original_tag = BRA
		}

		available = {
			has_completed_focus = BRA_amazonian_settlement
			NOT = {
				has_country_flag = BRA_amazonian_settlement_in_progress
			}
		}

		visible = {
			has_completed_focus = BRA_amazonian_settlement
		}

		state_target = yes

		target_trigger = {
			FROM = {
				is_owned_and_controlled_by = ROOT
				NOT = {
					OR = {
						has_state_flag = BRA_amazonian_settlement_complete
						state = 961
						state = 962
						state = 963
						state = 964
						state = 965
						state = 966
						state = 967
						state = 968
					}
				}
				OR = { 
					region = 285
					region = 163
				}
			}
		}
		on_map_mode = map_and_decisions_view
		cost = 50

		fire_only_once = yes
		days_remove = 35

		#modifier =

		complete_effect = {
			set_country_flag = BRA_amazonian_settlement_in_progress
		}

		remove_effect = {

			clr_country_flag = BRA_amazonian_settlement_in_progress

			FROM = {
				set_state_flag = BRA_amazonian_settlement_complete

				add_dynamic_modifier = {
					modifier = BRA_amazonian_settlement_modifier
				}
			}
		}
	}
}

BRA_jaguar_diplomacy_cat = {
	BRA_jaguar_diplomacy_decision = {
		icon = GFX_decision_eng_trade_unions_support

		allowed = {
			original_tag = BRA
		}

		visible = {
			has_completed_focus = BRA_jaguar_diplomacy		
		}

		available = {
			has_completed_focus = BRA_jaguar_diplomacy
			NOT = {
				has_country_flag = BRA_jaguar_diplomacy_in_progress
			}
			NOT = {
				has_war_with = FROM
			}	
			FROM = {
				has_opinion = {
					target = ROOT
					value > 25
				}
			}
		}

		#state_target = yes
		on_map_mode = map_and_decisions_view
		target_trigger = {
			FROM = {
				is_major = yes
				NOT = {
					has_country_flag = BRA_jaguar_diplomacy_enacted
					has_government = ROOT
				}
			}
		}
		cost = 25
		ai_will_do = {
			base = 10
			modifier = {
				factor = 5
				is_in_faction = no
			}
		}
		fire_only_once = no
		days_remove = 30

		complete_effect = {
			set_country_flag = BRA_jaguar_diplomacy_in_progress
		}

		remove_effect = {
			FROM = {
				country_event = {
					id = JUNO_brazil_events.140
					hours = 1
				}
			}
			custom_effect_tooltip = BRA_invite_to_organization_of_american_states_tt
		}
	}
}

BRA_oust_the_empires_decision_cat = {
	BRA_oust_the_empires_decision = {
		icon = GFX_decision_generic_political_rally
		target_array = BRA.anti_colonialist_countries_to_liberate
		target_root_trigger = { original_tag = BRA }
		fire_only_once = no
		target_non_existing = yes

		allowed = {
			original_tag = BRA
		}

		available = {
			NOT = {
				has_country_flag = BRA_liberation_in_progress
			}
		}

		visible = {
			FROM = {
				NOT = {
					has_country_flag = BRA_already_liberated_country
				}
			}
			
		}

		on_map_mode = decision_view_only
		
		cost = 50

		ai_will_do = {
			base = 5
			modifier = {
				factor = 0
				is_in_faction = yes
			}
		}

		days_remove = 30

		complete_effect = {
			hidden_effect = {
				BRA_setup_colonized_countries_to_liberate_array = yes #run again to see if there are any new countries that are occupied and needs liberation in south america, only shows up when decisions are reloaded
			}
			set_country_flag = BRA_liberation_in_progress #only one at a time, also to prevent weirdnes upon releasing countries
		}

		remove_effect = {
			FROM = { #country to be liberated
				save_global_event_target_as = BRA_country_to_be_liberated #since we remove from array, this is needed for the event that fires if they accept
				capital_scope = {
					OWNER = { #occupier 
						country_event = {
							id = JUNO_brazil_events.137
							hours = 1
						}
					}
				}

				for_each_scope_loop = {
					array = BRA.anti_colonialist_countries_to_liberate
					IF = {
						limit = {
							tag = FROM
						}
						remove_from_array = { #remove the country from the array so that 
							array = BRA.anti_colonialist_countries_to_liberate
							value = THIS #optional, use index or this. if neither it removes last element
						}
					}
				}
				set_country_flag = BRA_already_liberated_country
			}

			clr_country_flag = BRA_liberation_in_progress #clear that flag once done
			custom_effect_tooltip = BRA_oust_the_empires_decision_tt
		}
	}
}

BRA_sway_the_neighbors_cat = {
	BRA_sway_the_neighbors_decision = {
		icon = GFX_decision_generic_prepare_civil_war

		allowed = {
			original_tag = BRA
		}

		visible = {
			has_country_flag = BRA_sway_the_neighbors_no_lar		
		}

		available = {
			has_completed_focus = BRA_sway_the_neighbors
			FROM = {
				OWNER = {
					NOT = {
						has_country_flag = BRA_clamped_down_on_communism
					}	
				}
			}
		}

		state_target = yes
		on_map_mode = map_and_decisions_view
		target_trigger = {
			FROM = {
				is_capital = yes
				is_on_continent = south_america
				is_core_of = OWNER
				OWNER = {
					NOT = {
						OR = {
							has_idea = BRA_promoting_communism
							has_government = communism
							tag = ROOT
						}
					}
				}
			}
		}
		cost = 50

		fire_only_once = no
		days_remove = 30
		ai_will_do = {
			base = 4
		}
		complete_effect = {
			
		}

		remove_effect = {
			FROM = {
				OWNER = {
					country_event = {
						id = JUNO_brazil_events.143
						days = 15
						random_days = 5
					}
					add_timed_idea = {
						idea = BRA_promoting_communism
						days = 720
					}
				}
			}
		}
	}
}

BRA_counter_influence_cat = {
	BRA_counter_influence_decision = {
		icon = GFX_decision_eng_trade_unions_support

		allowed = {
			NOT = {
				original_tag = BRA
			}
		}

		visible = {
			has_country_flag = BRA_influencing_us
			has_idea = BRA_promoting_communism
		}

		available = {
			has_idea = BRA_promoting_communism
			NOT = {
				has_country_flag = BRA_clamped_down_on_communism
			}
		}

		cost = 100

		fire_only_once = no
		days_remove = 30
		ai_will_do = {
			base = 100
			modifier = {
				factor = 0
				has_government = communism
			}
		}

		complete_effect = {
			
		}

		remove_effect = {
			remove_ideas = BRA_promoting_communism
			hidden_effect = {
				BRA = {
					country_event = {
						id = JUNO_brazil_events.144
						days = 30
						random_days = 10
					}
				}
			}
		}
	}
}

BRA_invite_foreign_companies_cat = {
	BRA_invite_foreign_mio = {
		icon = GFX_decision_generic_industry
		allowed = {
			original_tag = BRA
		}
		visible = {
			has_completed_focus = BRA_invite_foreign_companies
		}
		available = {
			NOT = {
				has_country_flag = BRA_invite_company_in_progress
			}
			FROM = {
				has_opinion = {
					target = ROOT
					value > 25
				}
				NOT = {
					OR = {
						has_war_with = ROOT
						surrender_progress > 0.5
					}
				}
				has_government = democratic
			}
		}
		target_trigger = {
			FROM = {
				exists = yes
				OR = {
					original_tag = USA
					original_tag = ENG
					original_tag = FRA
					original_tag = SWE
				}
				has_government = democratic
				NOT = {
					OR = {
						has_country_flag = BRA_already_sent_mio
						has_capitulated = yes
						is_government_in_exile = yes
					}
				}
			}
		}
		cost = 30
		fire_only_once = no
		days_remove = 30
		ai_will_do = {
			base = 5
			modifier = {
				factor = 0
				has_war_with = FROM
			}
			modifier = {
				factor = 5
				is_in_faction_with = FROM
			}
			modifier = {
				factor = 2
				has_war = yes
			}
		}
		complete_effect = {
			set_country_flag = BRA_invite_company_in_progress	
		}
		remove_effect = {
			custom_effect_tooltip = BRA_invite_to_organization_of_american_states_tt
			FROM = {
				country_event = {
					id = JUNO_brazil_events.160
					hours = 1
				}
			}
		}
	}
}

BRA_america_do_sul_cat = {
	BRA_integrate_state = {
		icon = GFX_decision_generic_operation
		allowed = {
			original_tag = BRA
		}
		available = {
			has_stability > 0.25
			has_war_support > 0.25
			surrender_progress < 0.15
		    is_subject = no
			NOT = {
				has_country_flag = BRA_core_decision_active
			}
			has_completed_focus = BRA_unify_south_america
			surrender_progress < 0.05
		}
		
		visible = {
			any_owned_state = {
				is_on_continent = south_america
				NOT = {
					is_core_of = ROOT
				}
			}
		}
		state_target = yes
		target_trigger = {
		    FROM = {
		    	is_fully_controlled_by = ROOT
		    	is_on_continent = south_america
					NOT = { 
						is_core_of = ROOT 
						OR = {
							is_core_of = PAN
							is_core_of = NIC
							is_core_of = HON
							is_core_of = COS
							is_core_of = ELS
							is_core_of = CUB
							is_core_of = MEX
						}
					}
		    }
		}
		on_map_mode = map_and_decisions_view
		cost = 25
		ai_will_do = {
			base = 50
			modifier = {
				factor = 10
				any_owned_state = {
					NOT = {
						is_core_of = ROOT
					}
					is_on_continent = south_america
				}
			}
		}
		fire_only_once = no
		days_remove = 70

		modifier = {
			political_power_factor = -0.15
			consumer_goods_factor = 0.15
			production_speed_buildings_factor = -0.15
		}
		complete_effect = {
			#set_country_flag = BRA_core_decision_active
		}
		remove_effect = {
            add_stability = -0.01
            add_war_support = -0.01
			#clr_country_flag = BRA_core_decision_active
			FROM = {
				add_core_of = ROOT
			}
		}
	}
}

BRA_us_of_south_america_cat = {
	BRA_invite_to_ussa = {
		icon = GFX_decision_infiltrate_state
		allowed = {
			original_tag = BRA
		}
		visible = {
			has_completed_focus = BRA_united_states_of_south_america
		}
		available = {
		    is_subject = no
			has_stability > 0.25
			has_war_support > 0.25
			surrender_progress < 0.15
			NOT = {
				has_country_flag = BRA_invite_country_in_progress
			}
			FROM = {
				has_opinion = {
					target = ROOT
					value > 50
				}
				is_in_faction_with = ROOT
				surrender_progress < 0.05
				OR = {
					has_government = democratic
					has_government = neutrality
				}
			}
		}
		target_trigger = {
			FROM = {
				exists = yes
					NOT = { 
						OR = {
							original_tag = PAN
							original_tag = NIC
							original_tag = HON
							original_tag = COS
							original_tag = ELS
							original_tag = CUB
							original_tag = MEX
						}
					}
				OR = {
					is_in_faction_with = ROOT
					is_subject_of = ROOT
				}
				OR = {
					has_government = democratic
					has_government = neutrality
				}				
				has_capitulated = no
				is_government_in_exile = no		
				capital_scope = {
					is_on_continent = south_america
					is_core_of = PREV
				}			
			}
		}
		cost = 50
		fire_only_once = no
		days_remove = 70
		modifier = {
			political_power_factor = -0.15
			production_speed_buildings_factor = -0.15
			consumer_goods_factor = 0.15
		}
		
		ai_will_do = {
			base = 5
			modifier = {
				factor = 0
				has_war_with = FROM
			}
			modifier = {
				factor = 10
				is_in_faction_with = FROM
			}
			modifier = {
				factor = 2
				has_war = no
			}
		}
		complete_effect = {
			set_country_flag = BRA_invite_country_in_progress	
		}
		remove_effect = {
            add_stability = -0.01
            add_war_support = -0.01
			custom_effect_tooltip = BRA_invite_to_organization_of_american_states_tt
			FROM = {
				country_event = {
					id = JUNO_brazil_events.170
					hours = 6
				}
			}
		}
	}

	BRA_invite_to_faction = {
		icon = GFX_decision_eng_trade_unions_support
		allowed = {
			original_tag = BRA
		}
		visible = {
			has_completed_focus	= BRA_reach_out_to_our_neighbors
		}
		available = {
			has_completed_focus	= BRA_reach_out_to_our_neighbors
			is_subject = no
			surrender_progress < 0.1
			FROM = {
			    surrender_progress < 0.05
				has_opinion = {
					target = ROOT
					value > 30
				}
			}
			NOT = {
				has_war_with = FROM
			}
		}
		on_map_mode = map_and_decisions_view
		target_trigger = {
		    FROM = { 
					NOT = { 
						OR = {
							original_tag = PAN
							original_tag = NIC
							original_tag = HON
							original_tag = COS
							original_tag = ELS
							original_tag = CUB
							original_tag = MEX
							original_tag = CHL
							original_tag = ARG
						}
					}
		    	AND = {
		    		NOT = { 
		    			is_in_faction_with = ROOT
		    			tag = ROOT
		    		}
		    		OR = { 
		    			is_subject = no
		    			is_subject_of = ROOT
		    		}
		    	}
		    	capital_scope = { is_on_continent = south_america }
		    }
		}
		cost = 50
		ai_will_do = {
			base = 35
			modifier = {
				factor = 0
				is_in_faction = yes
			}
		}
		fire_only_once = no
		days_remove = 20
		
		modifier = {
			production_speed_buildings_factor = -0.1
			consumer_goods_factor = 0.1
		}
		
		remove_effect = {
			FROM = {
				country_event = {
					id = generic.5
					hours = 1
				}
			}
			#custom_effect_tooltip = BRA_invite_to_organization_of_american_states_tt
		}
	}	
}

BRA_foreign_legion_cat = {
	BRA_recruit_foreign_legion = {
		icon = GFX_decision_generic_prepare_civil_war

		allowed = {
			original_tag = BRA
		}

		visible = {
			has_completed_focus = BRA_foreign_legion
		}

		available = {
			NOT = {
				has_country_flag = BRA_foreign_legion_recruitment_in_progress
			}
		}

		custom_cost_trigger = {
			command_power > 24.9
		}
		custom_cost_text = BRA_decision_cost_cangaceiro

		#cost = 100

		fire_only_once = no
		days_remove = 60
		ai_will_do = {
			base = 100
			modifier = {
				factor = 0
				has_government = communism
			}
		}

		complete_effect = {
			set_country_flag = BRA_foreign_legion_recruitment_in_progress
			add_command_power = -25
		}

		remove_effect = {
			capital_scope = {
				create_unit = {
					division = "division_template =\"Legião Estrangeira\" start_experience_factor = 0.2 start_equipment_factor	= 1.0"
					owner = ROOT
					count = 1
				} 
			}
			hidden_effect = {
				clr_country_flag = BRA_foreign_legion_recruitment_in_progress
			}
		}
	}
}