﻿###########################
# Portugal Events
###########################

add_namespace = lar_portugal_iberian_summit
add_namespace = lar_portugal_navy_mutiny
add_namespace = lar_portugal_iberian_workers_united
add_namespace = lar_portugal_naval_blockade
add_namespace = lar_portugal_purchase_ships
add_namespace = lar_portugal_promote_monarchist_cause
add_namespace = lar_portugal_spanish_civil_war
add_namespace = lar_portugal_royal_iberian_alliance
add_namespace = lar_portugal_overseas_provinces


######## IBERIAN SUMMIT ########
# Iberian summit - country suggests joining axis
country_event = {
	id = lar_portugal_iberian_summit.1
	title = lar_portugal_iberian_summit.1.t
	desc = lar_portugal_iberian_summit.1.desc
	picture = GFX_report_event_generic_read_write

	is_triggered_only = yes

	# Join immediately
	option = {
		name = lar_portugal_iberian_summit.1.a

		ai_chance = {
			base = 20
			modifier = { 	# Opinion of Faction Leader
				add = 20
				has_opinion = { target = GER value > 40 }
			}
			modifier = {	# Opinion of FROM
				add = 20
				has_opinion = { target = FROM value > 40 }
			}
			modifier = {	# Faction strength ratio against its enemies
				add = 20
				GER = { 
					has_war = yes 
					alliance_strength_ratio > 0.99
				}
			}
			modifier = {	# Faction War Score
				add = 20
				GER = {
					has_war = yes 
					any_war_score > 49
				}
			}
			modifier = {	# Very bad opinion of Faction Leader / FROM will lock this option
				factor = 0
				OR = {
					has_opinion = { target = GER value < -20 }
					has_opinion = { target = FROM value < -20 }
					AND = {
						tag = POR
						NOT = { has_completed_focus = POR_estado_novo }
					}
				}
			}
		}
		custom_effect_tooltip =  lar_portugal_iberian_summit.1_a_tt
		effect_tooltip = {
			GER  = { country_event = lar_portugal_iberian_summit.4 }
		}
		hidden_effect = { FROM = { country_event = lar_portugal_iberian_summit.2 } }
		FROM = {
			add_opinion_modifier = {
				target = ROOT
				modifier = POR_iberian_summit_working_together
			}
		}
		ROOT = {
			add_opinion_modifier = {
				target = FROM
				modifier = POR_iberian_summit_working_together
			}
		}
	}

	# Join in 6 months
	option = {
		name = lar_portugal_iberian_summit.1.b

		ai_chance = {
			base = 40
			modifier = {	# Faction strength ratio against its enemies
				add = 20
				GER = { 
					has_war = yes 
					AND = {
						alliance_strength_ratio > 0.74
						alliance_strength_ratio < 1
					}
				}
			}
			modifier = {	# Faction War Score
				add = 20
				GER = {
					has_war = yes 
					AND = {
						any_war_score > 29
						any_war_score < 50
					}
				}
			}
			modifier = {	# Stronger faction member has WG or is justfying against ROOT
				add = 20
				GER = {
					any_allied_country = {
						OR = {
							has_wargoal_against = ROOT
							is_justifying_wargoal_against = ROOT
						}
						strength_ratio = {
						    tag = ROOT
						    ratio > 1.24
						}
					}
				}
			}
			modifier = {	# Wants to improve relations with Faction Leader in order to succeed
				add = 20
				has_opinion = { target = GER value > 0 }
				has_opinion = { target = FROM value > 0 }
				OR = {
					GER = { 
						has_opinion =  { target = ROOT value < 0 }
					}
					GER = { 
						has_opinion =  { target = FROM value < 0 }
					}
				}
			}
			modifier = {	# Very bad opinion of Faction Leader / FROM will lock this option
				factor = 0
				OR = {
					has_opinion = { target = GER value < -30 }
					has_opinion = { target = FROM value < -30 }
					AND = {
						tag = POR
						NOT = { has_completed_focus = POR_estado_novo }
					}
				}
			}
		}
		custom_effect_tooltip =  lar_portugal_iberian_summit.1_b_tt

		hidden_effect = { FROM = { country_event = lar_portugal_iberian_summit.3 } }
		FROM = {
			add_opinion_modifier = {
				target = ROOT
				modifier = POR_iberian_summit_working_together
			}
			activate_decision = POR_iberian_summit_proposal_delayed
		}
		ROOT = {
			add_opinion_modifier = {
				target = FROM
				modifier = POR_iberian_summit_working_together
			}
			activate_decision = POR_iberian_summit_proposal_delayed
		}
		set_global_flag = POR_iberian_summit_proposal_delayed_flag
	}
	# Don't join
	option = {
		name = lar_portugal_iberian_summit.1.c

		ai_chance = {
			base = 40
			modifier = { 	# Opinion of Faction Leader
				add = 20
				has_opinion = { target = GER value < 0 }
			}
			modifier = {	# Opinion of FROM
				add = 20
				has_opinion = { target = FROM value < 0 }
			}
			modifier = {	# Faction strength ratio against its enemies
				add = 20
				GER = { 
					has_war = yes 
					alliance_strength_ratio < 0.75
				}
			}
			modifier = {	# Faction War Score
				add = 20
				GER = {
					has_war = yes 
					any_war_score < 30
				}
			}
			modifier = {	# Weak faction member has WG or is justfying against ROOT
				add = 20
				GER = {
					any_allied_country = {
						OR = {
							has_wargoal_against = ROOT
							is_justifying_wargoal_against = ROOT
						}
						strength_ratio = {
						    tag = ROOT
						    ratio < 1
						}
					}

				}
			}
			modifier = {	# Historical Focus will potentially enforce this option
				factor = 5
				is_historical_focus_on = yes
			}
		}

		hidden_effect = {
			FROM = { country_event = lar_portugal_iberian_summit.9 }
		}
	}
}

# Join Axis Now
country_event = {
	id = lar_portugal_iberian_summit.2
	title = lar_portugal_iberian_summit.2.t
	desc = lar_portugal_iberian_summit.2.desc
	picture = GFX_report_event_generic_sign_treaty1

	is_triggered_only = yes

	option = {
		name = lar_portugal_iberian_summit.2.a	

		GER = {
			country_event = { id = lar_portugal_iberian_summit.4 days = 1 }
		}	
		effect_tooltip = {
			FROM = {
				add_opinion_modifier = {
					target = ROOT
					modifier = POR_iberian_summit_working_together
				}
			}
			ROOT = {
				add_opinion_modifier = {
					target = FROM
					modifier = POR_iberian_summit_working_together
				}
			}
		}
	}
}

# Join Axis Later
country_event = {
	id = lar_portugal_iberian_summit.3
	title = lar_portugal_iberian_summit.3.t
	desc = lar_portugal_iberian_summit.3.desc
	picture = GFX_report_event_generic_conference

	is_triggered_only = yes

	option = {
		name = lar_portugal_iberian_summit.3.a
		custom_effect_tooltip = lar_portugal_iberian_summit.1_b_tt
		effect_tooltip = {
			FROM = {
				add_opinion_modifier = {
					target = ROOT
					modifier = POR_iberian_summit_working_together
				}
				activate_decision = POR_iberian_summit_proposal_delayed
			}
			ROOT = {
				add_opinion_modifier = {
					target = FROM
					modifier = POR_iberian_summit_working_together
				}
				activate_decision = POR_iberian_summit_proposal_delayed
			}
		}
	}
}

# Event for Germany - POR & SPA asks to join Faction
country_event = {
	id = lar_portugal_iberian_summit.4
	title = lar_portugal_iberian_summit.4.t
	desc = lar_portugal_iberian_summit.4.desc
	picture = GFX_report_event_por_salazar_franco1

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			save_event_target_as = alliance_inviter
			clear_variable = global.POR_iberian_summit_target
		}
	}

	# Accept them
	option = {
		name = lar_portugal_iberian_summit.4.a 

		ai_chance = {
			base = 50
			modifier = {	# Good Opinion of Portugal
				add = 25
				has_opinion = { target = POR value > 10 }
			}
			modifier = {	# Good Opinion of Spain
				add = 25
				has_opinion = { target = SPA value > 10 }
			}
			modifier = {	# Bad strength ratio
				factor = 1.5
				alliance_strength_ratio < 1
			}				
			modifier = {	# Not making progress in wars
				factor = 1.5
				any_war_score < 50
			}
		}

		hidden_effect = {
			news_event = { id = lar_news.24 days = 3 random_days = 5 }
		}

		add_to_faction = POR
		add_to_faction = SPA
		hidden_effect = {
			POR = { country_event = generic.3 }
			SPA = { country_event = generic.3 }
		}
		clr_global_flag = POR_iberian_summit_in_progress_flag
		set_global_flag = POR_iberian_summit_successful_flag
	}
	# Deny
	option = {
		name = lar_portugal_iberian_summit.4.b

		ai_chance = {
			base = 50
			modifier = {	# Bad Opinion of Portugal
				add = 25
				has_opinion = { target = POR value < -10 }
			}
			modifier = {	# Bad Opinion of Spain
				add = 25
				has_opinion = { target = SPA value < -10 }
			}	
			modifier = {	# Has War Goal or is justifying in Iberian countries
				factor = 100
				OR = {
					has_wargoal_against = POR
					is_justifying_wargoal_against = POR
					has_wargoal_against = SPA
					is_justifying_wargoal_against = SPA
				}
			}
			modifier = {	# Ally has War Goal or is justifying in Iberian countries
				factor = 2
				any_allied_country = {
					OR = {
						has_wargoal_against = POR
						is_justifying_wargoal_against = POR
						has_wargoal_against = SPA
						is_justifying_wargoal_against = SPA
					}
				}
			}			
		}

		POR = { country_event = generic.4 }
		SPA = { country_event = generic.4 }
		clr_global_flag = POR_iberian_summit_in_progress_flag
	}
}

# Iberian summit - country suggests joining allies
country_event = {
	id = lar_portugal_iberian_summit.5

	title = lar_portugal_iberian_summit.5.t
	desc = lar_portugal_iberian_summit.5.desc
	picture = GFX_report_event_generic_read_write

	is_triggered_only = yes

	# join immediately
	option = {
		name = lar_portugal_iberian_summit.5.a

		ai_chance = {
			base = 20
			modifier = { 	# Opinion of Faction Leader
				add = 20
				has_opinion = { target = ENG value > 40 }
			}
			modifier = {	# Opinion of FROM
				add = 20
				has_opinion = { target = FROM value > 40 }
			}
			modifier = {	# Faction strength ratio against its enemies
				add = 20
				ENG = { 
					has_war = yes 
					alliance_strength_ratio > 0.99
				}
			}
			modifier = {	# Faction War Score
				add = 20
				ENG = {
					has_war = yes 
					any_war_score > 49
				}
			}

			modifier = {	# Very bad opinion of Faction Leader or FROM will lock this option
				factor = 0
				OR = {
					has_opinion = { target = ENG value < 20 }
					has_opinion = { target = FROM value < 20 }
					AND = {
						tag = POR
						NOT = { 
							OR = {
								has_completed_focus = POR_support_the_spanish_republic 
								has_completed_focus = POR_strict_neutrality_in_the_spanish_civil_war
							}
						}
					}
					AND = {
						tag = SPA
						NOT = { 
							has_completed_focus = SPA_unify_the_nationalist_front
						}
						NOT = { has_government = fascism }
					}
					AND = {
						tag = SPD
						NOT = { has_completed_focus = SPR_maintain_the_second_republic }
					}
				}
			}
		}

		custom_effect_tooltip =  lar_portugal_iberian_summit.5_a_tt
		effect_tooltip = {
			ENG  = { country_event = lar_portugal_iberian_summit.8 }
		}
		hidden_effect = { FROM = { country_event = lar_portugal_iberian_summit.6 } }
		FROM = {
			add_opinion_modifier = {
				target = ROOT
				modifier = POR_iberian_summit_working_together
			}
		}
		ROOT = {
			add_opinion_modifier = {
				target = FROM
				modifier = POR_iberian_summit_working_together
			}
		}
	}

	# join in 6 months
	option = {
		name = lar_portugal_iberian_summit.5.b

		ai_chance = {
			base = 40
			modifier = {	# Faction strength ratio against its enemies
				add = 20
				ENG = { 
					has_war = yes 
					AND = {
						alliance_strength_ratio > 0.74
						alliance_strength_ratio < 1
					}
				}
			}
			modifier = {	# Faction War Score
				add = 20
				ENG = {
					has_war = yes 
					AND = {
						any_war_score > 29
						any_war_score < 50
					}
				}
			}
			modifier = {	# Stronger faction member has WG or is justfying against ROOT
				add = 20
				ENG = {
					any_allied_country = {
						OR = {
							has_wargoal_against = ROOT
							is_justifying_wargoal_against = ROOT
						}
						strength_ratio = {
						    tag = ROOT
						    ratio > 1.24
						}
					}

				}
			}
			modifier = {	# Wants to improve relations with Faction Leader in order to succeed
				add = 20
				has_opinion = { target = ENG value > 0 }
				has_opinion = { target = FROM value > 0 }
				OR = {
					ENG = { 
						has_opinion =  { target = ROOT value < 0 }
					}
					ENG = { 
						has_opinion =  { target = FROM value < 0 }
					}
				}
			}
			modifier = {	# Very bad opinion of Faction Leader or FROM will lock this option
				factor = 0
				OR = {
					has_opinion = { target = ENG value < 30 }
					has_opinion = { target = FROM value < 30 }
					AND = {
						tag = POR
						NOT = { 
							OR = {
								has_completed_focus = POR_support_the_spanish_republic 
								has_completed_focus = POR_strict_neutrality_in_the_spanish_civil_war
							}
						}
					}
					AND = {
						tag = SPA
						NOT = { 
							has_completed_focus = SPA_unify_the_nationalist_front
						}
					}
					AND = {
						tag = SPD
						NOT = { has_completed_focus = SPR_maintain_the_second_republic }
					}
				}
			}
		}

		custom_effect_tooltip =  lar_portugal_iberian_summit.5_b_tt
		hidden_effect = { FROM = { country_event = lar_portugal_iberian_summit.7 } }
		FROM = {
			add_opinion_modifier = {
				target = ROOT
				modifier = POR_iberian_summit_working_together
			}
			activate_decision = POR_iberian_summit_proposal_delayed
		}
		ROOT = {
			add_opinion_modifier = {
				target = FROM
				modifier = POR_iberian_summit_working_together
			}
			activate_decision = POR_iberian_summit_proposal_delayed
		}
		set_global_flag = POR_iberian_summit_proposal_delayed_flag
	}
	# don't join
	option = {
		name = lar_portugal_iberian_summit.5.c

		ai_chance = {
			base = 40
			modifier = { 	# Opinion of Faction Leader
				add = 20
				has_opinion = { target = ENG value < 0 }
			}
			modifier = {	# Opinion of FROM
				add = 20
				has_opinion = { target = FROM value < 0 }
			}
			modifier = {	# Faction strength ratio against its enemies
				add = 20
				ENG = { 
					has_war = yes 
					alliance_strength_ratio < 0.75
				}
			}
			modifier = {	# Faction War Score
				add = 20
				ENG = {
					has_war = yes 
					any_war_score < 30
				}
			}
			modifier = {	# Weak faction member has WG or is justfying against ROOT
				add = 20
				ENG = {
					any_allied_country = {
						OR = {
							has_wargoal_against = ROOT
							is_justifying_wargoal_against = ROOT
						}
						strength_ratio = {
						    tag = ROOT
						    ratio < 1
						}
					}

				}
			}
			modifier = {	# Historical Focus will potentially enforce this option
				factor = 5
				is_historical_focus_on = yes
			}
		}

		FROM = { country_event = lar_portugal_iberian_summit.9 }
	}

}

# Join Allies Now
country_event = {
	id = lar_portugal_iberian_summit.6
	title = lar_portugal_iberian_summit.6.t
	desc = lar_portugal_iberian_summit.6.desc
	picture = GFX_report_event_generic_sign_treaty1

	is_triggered_only = yes

	option = {
		name = lar_portugal_iberian_summit.6.a	
		ENG = {
			country_event = { id = lar_portugal_iberian_summit.8 days = 1 }
		}
		effect_tooltip = {
			FROM = {
				add_opinion_modifier = {
					target = ROOT
					modifier = POR_iberian_summit_working_together
				}
			}
			ROOT = {
				add_opinion_modifier = {
					target = FROM
					modifier = POR_iberian_summit_working_together
				}
			}
		}
	}
}

# Join Allies Later
country_event = {
	id = lar_portugal_iberian_summit.7
	title = lar_portugal_iberian_summit.7.t
	desc = lar_portugal_iberian_summit.7.desc
	picture = GFX_report_event_generic_conference

	is_triggered_only = yes

	option = {
		name = lar_portugal_iberian_summit.7.a

		custom_effect_tooltip =  lar_portugal_iberian_summit.5_b_tt
		effect_tooltip = {
			FROM = {
				add_opinion_modifier = {
					target = ROOT
					modifier = POR_iberian_summit_working_together
				}
				activate_decision = POR_iberian_summit_proposal_delayed
			}
			ROOT = {
				add_opinion_modifier = {
					target = FROM
					modifier = POR_iberian_summit_working_together
				}
				activate_decision = POR_iberian_summit_proposal_delayed
			}
		}
	}
}

# Event for ENG - POR & SPD/SPA asks to join Faction
country_event = {
	id = lar_portugal_iberian_summit.8
	title = lar_portugal_iberian_summit.8.t
	desc = lar_portugal_iberian_summit.8.desc
	picture = GFX_report_event_por_salazar_franco1

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			save_event_target_as = alliance_inviter
			clear_variable = global.POR_iberian_summit_target
		}
	}

	# Accept them
	option = {
		name = lar_portugal_iberian_summit.8.a 

		ai_chance = {
			base = 50
			modifier = {	# Good Opinion of Portugal
				add = 25
				has_opinion = { target = POR value > 10 }
			}
			modifier = {	# Good Opinion of Spain
				add = 25
				OR = {
					country_exists = SPA
					has_opinion = { target = SPA value > 10 }
				}
				OR = {
					country_exists = SPD
					has_opinion = { target = SPD value > 10 }
				}				
			}
			modifier = {	# Bad strength ratio
				factor = 1.5
				alliance_strength_ratio < 1
			}				
			modifier = {	# Not making progress in wars
				factor = 1.5
				any_war_score < 50
			}
		}

		hidden_effect = {
			news_event = { id = lar_news.23 days = 3 random_days = 5 }
		}

		add_to_faction = POR
		hidden_effect = { 
			POR = { country_event = generic.3 } 
		}
		if = {
			limit = { country_exists = SPD }
			add_to_faction = SPD
			hidden_effect = {
				SPD = { country_event = generic.3 }
			}
		}
		else = {
			add_to_faction = SPA
			hidden_effect = { 
				SPA = { country_event = generic.3 }
			}
		}
		clr_global_flag = POR_iberian_summit_in_progress_flag
		set_global_flag = POR_iberian_summit_successful_flag

	}
	# Deny
	option = {
		name = lar_portugal_iberian_summit.8.b

		ai_chance = {
			base = 50
			modifier = {	# Bad Opinion of Portugal
				add = 25
				has_opinion = { target = POR value < -10 }
			}
			modifier = {	# Bad Opinion of Spain
				add = 25
				OR = {
					country_exists = SPA
					has_opinion = { target = SPA value < -10 }
				}
				OR = {
					country_exists = SPD
					has_opinion = { target = SPD value < -10 }
				}
			}	
			modifier = {	# Has War Goal or is justifying in Iberian countries
				factor = 100
				OR = {
					has_wargoal_against = POR
					is_justifying_wargoal_against = POR
					has_wargoal_against = global.POR_iberian_summit_spanish_tag
					is_justifying_wargoal_against = global.POR_iberian_summit_spanish_tag
				}
			}
			modifier = {	# Ally has War Goal or is justifying in Iberian countries
				factor = 2
				any_allied_country = {
					OR = {
						has_wargoal_against = POR
						is_justifying_wargoal_against = POR
						has_wargoal_against = global.POR_iberian_summit_spanish_tag
						is_justifying_wargoal_against = global.POR_iberian_summit_spanish_tag
					}
				}
			}			
		}
		
		POR = { country_event = generic.4 }
		if = {
		limit = { country_exists = SPD }
			SPD = { country_event = generic.4 }
		}
		else = {
			SPA = { country_event = generic.4 }
		}
		clr_global_flag = POR_iberian_summit_in_progress_flag
	}
}

# Proposal declined
country_event = {
	id = lar_portugal_iberian_summit.9
	title = lar_portugal_iberian_summit.9.t
	desc = lar_portugal_iberian_summit.9.desc
	picture = GFX_report_event_por_estado_novo

	is_triggered_only = yes

	option = {
		name = lar_portugal_iberian_summit.9.a

		clr_global_flag = POR_iberian_summit_in_progress_flag
	}
}


######## NAVY MUTINY ########
# Navy Mutiny - Mutineers want to help SPD in the SCW
country_event = {
	id = lar_portugal_navy_mutiny.1
	title = lar_portugal_navy_mutiny.1.t
	desc = lar_portugal_navy_mutiny.1.desc
	picture = GFX_report_event_destroyers

	mean_time_to_happen = { days = 120 }

	fire_only_once = yes

	trigger = {
		original_tag = POR
		SPR_scw_in_progress = yes
		country_exists = SPD
		NOT = { has_completed_focus = POR_support_the_spanish_republic }
	}

	immediate = {
		set_variable = { transfer_target = SPD }
		set_variable = { POR_ships_revolted = 0 }
	}

	# Allow them to leave port (Only Popular Front)
	option = {
		name = lar_portugal_navy_mutiny.1.a

		ai_chance = {
			base = 50
		}

		trigger = {
			has_completed_focus = POR_popular_front
		}
		hidden_effect = {
			transfer_ship = {
			    prefer_name = "NRP Dão"
			    type = destroyer
			    target = transfer_target 
			}
			add_to_variable = { POR_ships_revolted = 1 } # 1
			if = {
				limit = {
					communism > 0.1
				}
				transfer_ship = {
				    type = destroyer
				    prefer_name = "NRP Douro"
				    target = transfer_target
				}
				add_to_variable = { POR_ships_revolted = 1 } # 2
			}
			if = {
				limit = {
					communism > 0.25
				}
				transfer_ship = {
				    type = destroyer
				    prefer_name = "NRP Tejo"
				    target = transfer_target
				}
				add_to_variable = { POR_ships_revolted = 1 } # 3
			}
			if = {
				limit = {
					communism > 0.4
				}
				transfer_ship = {
				    type = destroyer
				    prefer_name = "NRP Tamega"
				    target = transfer_target
				}
				add_to_variable = { POR_ships_revolted = 1 } # 4
			}
			if = {
				limit = {
					communism > 0.6
				}
				transfer_ship = {
				    type = destroyer
				    prefer_name = "NRP Vouga"
				    target = transfer_target
				}
				add_to_variable = { POR_ships_revolted = 1 } # 5
			}
			if = {
				limit = {
					communism > 0.75
				}
				transfer_ship = {
				    type = destroyer
				    prefer_name = "NRP Lima"
				    target = transfer_target
				}
				add_to_variable = { POR_ships_revolted = 1 } # 6
			}

			set_variable = { POR_ships_revolted_not_including_dao = POR_ships_revolted }
			add_to_variable = {POR_ships_revolted_not_including_dao = -1 }

			set_country_flag = POR_navy_mutiny_allowed_flag
			SPD = { country_event = { id = lar_portugal_navy_mutiny.4 } }
			country_event = { id = lar_portugal_navy_mutiny.2 days = 1 }
		}
		custom_effect_tooltip = lar_portugal_navy_mutiny.1_allow_tt
	}

	# Stop those mutineers
	option = {
		name = lar_portugal_navy_mutiny.1.b

		ai_chance = {
			base = 50
		}

		hidden_effect = {
			set_temp_variable = { opposition_factor = party_popularity@neutrality }
			add_to_temp_variable = { opposition_factor = party_popularity@fascism }
			add_to_temp_variable = { opposition_factor = party_popularity@democratic }
			multiply_temp_variable = { opposition_factor = 100 }

			set_temp_variable = { communist_factor = party_popularity@communism }
			multiply_temp_variable = { communist_factor = 300 } #Probability to suceed

			random_list = {
				temp_var:opposition_factor = {
				}
				temp_var:communist_factor = {
					add_to_variable = { POR_ships_revolted = 1 } # 1

					set_temp_variable = { communist_factor = party_popularity@communism }
					multiply_temp_variable = { communist_factor = 250 } #Probability to suceed
					random_list = {
						temp_var:opposition_factor = {
						}
						temp_var:communist_factor = {
							add_to_variable = { POR_ships_revolted = 1 } # 2

							set_temp_variable = { communist_factor = party_popularity@communism }
							multiply_temp_variable = { communist_factor = 200 } #Probability to suceed
							random_list = {
								temp_var:opposition_factor = {
								}
								temp_var:communist_factor = {
									add_to_variable = { POR_ships_revolted = 1 } # 3

									set_temp_variable = { communist_factor = party_popularity@communism }
									multiply_temp_variable = { communist_factor = 100 } #Probability to suceed
									random_list = {
										temp_var:opposition_factor = {
										}
										temp_var:communist_factor = {
											add_to_variable = { POR_ships_revolted = 1 } # 4
										}
									}
								}
							}
						}
					}
				}
			}
			country_event = { id = lar_portugal_navy_mutiny.3 days = 1 }
		}
		custom_effect_tooltip = lar_portugal_navy_mutiny.1_stop_tt
	}
}

# Mutiny Report -> Government allowed ships to head to SPD
country_event = {
	id = lar_portugal_navy_mutiny.2
	title = lar_portugal_navy_mutiny.2.t
	# Desc when only Dão heads to SPD
	desc = {
		text = lar_portugal_navy_mutiny.2.desc
		trigger = {
			check_variable = { POR_ships_revolted = 1 }
		}
	}
	# Desc when other ships follow Dão to SPD
	desc = {
		text = lar_portugal_navy_mutiny.2_extra.desc
		trigger = {
			check_variable = { POR_ships_revolted > 1 }			
		}
	}
	picture = GFX_report_event_ast_navy

	is_triggered_only = yes

	option = {
		name = lar_portugal_navy_mutiny.2.a
		hidden_effect = { 
			SPD = { set_country_flag = POR_got_portuguese_mutineers_flag }
		}
		# Add Dão (previously not added) to the array to transfer the correct ammount of ships back after SCW
		custom_effect_tooltip = lar_portugal_navy_mutiny.2_tt
	}
}

# Mutiny Report -> Government fought the fleeing ships
country_event = {
	id = lar_portugal_navy_mutiny.3
	title = lar_portugal_navy_mutiny.3.t
	# Desc when no ships make it out of harbour
	desc = {
		text = lar_portugal_navy_mutiny.3.desc
		trigger = {
			check_variable = { POR_ships_revolted = 0 }	
		}
	}
	# Desc when any ship makes it out of harbour
	desc = {
		text = lar_portugal_navy_mutiny.3_extra.desc
		trigger = {
			check_variable = { POR_ships_revolted > 0 }	
		}
	}
	picture = GFX_report_event_portugal_navy_mutiny_prisoners

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			if = { 
				limit = { 
					check_variable = { POR_ships_revolted > 0 }
				}
				transfer_ship = {
				    type = destroyer
				    prefer_name = "NRP Dão"
				    target = transfer_target
				}
				if = {
					limit = {
						check_variable = { POR_ships_revolted > 1 }
					}
					transfer_ship = {
					    type = destroyer
					    prefer_name = "NRP Douro"
					    target = transfer_target
					}
					if = {
						limit = {
							check_variable = { POR_ships_revolted > 2 }
						}
						transfer_ship = {
						    type = destroyer
						    prefer_name = "NRP Tejo"
						    target = transfer_target
						}
						if = {
							limit = {
								check_variable = { POR_ships_revolted > 3 }
							}
							transfer_ship = {
							    type = destroyer
							    prefer_name = "NRP Tamega"
							    target = transfer_target
							}
						}
					}
				}
				SPD = { 
					country_event = { id = lar_portugal_navy_mutiny.4 } 
					set_country_flag = POR_got_portuguese_mutineers_flag
				}
			}
		}
	}

	option = { 
		name = lar_portugal_navy_mutiny.3.a
		add_manpower = -500
		if = {
			limit = {
				check_variable = { POR_ships_revolted = 0 }
			}
			custom_effect_tooltip = lar_portugal_navy_mutiny.3_no_ships_tt
		}
		else = {
			custom_effect_tooltip = lar_portugal_navy_mutiny.3_ships_tt
		}
	}
}

# Spanish Republic receives ships -> Event for Spain
country_event = {
	id = lar_portugal_navy_mutiny.4
	title = lar_portugal_navy_mutiny.4.t

	desc = { #Mutiny allowed
		text = lar_portugal_navy_mutiny.4.desc
		trigger = {
			POR = { has_country_flag = POR_navy_mutiny_allowed_flag }
		}
	}

	desc = { #Mutiny was not allowed
		text = lar_portugal_navy_mutiny.4_extra.desc
		trigger = {
			POR = { NOT = { has_country_flag = POR_navy_mutiny_allowed_flag } }
		}
	}

	picture = GFX_report_event_ast_navy

	is_triggered_only = yes

	option = { 
		name = lar_portugal_navy_mutiny.4.a

		custom_effect_tooltip = lar_portugal_navy_mutiny.4_tt
	}
}

# Event for POR: Spain sends ships back in compensation after SCW
country_event = {
	id = lar_portugal_navy_mutiny.5
	title = lar_portugal_navy_mutiny.5.t

	desc = lar_portugal_navy_mutiny.5.desc

	picture = GFX_report_event_ast_navy

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			random_country = {
				limit = {
					original_tag = SPR
					has_country_flag = POR_got_portuguese_mutineers_flag
				}
				country_event = lar_portugal_navy_mutiny.6
			}
		}
	}

	option = { 
		name = lar_portugal_navy_mutiny.5.a
		custom_effect_tooltip = lar_portugal_navy_mutiny.5_tt
	}
}

# Event for SPD: Spain sends ships back in compensation after SCW
country_event = {
	id = lar_portugal_navy_mutiny.6
	title = lar_portugal_navy_mutiny.6.t

	desc = lar_portugal_navy_mutiny.6.desc

	picture = GFX_report_event_sailors_in_working_rig

	is_triggered_only = yes

	immediate = {
		transfer_ship = {
			type = destroyer
			prefer_name = "NRP Dão"
			target = POR
		}
		POR = {
			if = {
				limit = {
					check_variable = { POR_ships_revolted > 1 }
				}
				ROOT = {
					transfer_ship = {
						type = destroyer
						prefer_name = "NRP Douro"
						target = POR
					}
				}
				if = {
					limit = {
						check_variable = { POR_ships_revolted > 2 }
					}
					ROOT = {
						transfer_ship = {
							type = destroyer
							prefer_name = "NRP Tejo"
							target = POR
						}
					}
					if = {
						limit = {
							check_variable = { POR_ships_revolted > 3 }
						}
						ROOT = {
							transfer_ship = {
								type = destroyer
								prefer_name = "NRP Tamega"
								target = POR
							}
						}
					}
				}
			}
		}
	}

	option = { 
		name = lar_portugal_navy_mutiny.6.a
		hidden_effect = {
			clr_country_flag = POR_got_portuguese_mutineers_flag
		}
		#custom_effect_tooltip = lar_portugal_navy_mutiny.6_tt
	}
}


###### IBERIAN WORKERS UNITED #####
# Iberian Workers United
country_event = {
	id = lar_portugal_iberian_workers_united.1
	title = lar_portugal_iberian_workers_united.1.t
	desc = lar_portugal_iberian_workers_united.1.desc
	picture = GFX_report_event_generic_rifles

	is_triggered_only = yes

	option = {
		name = lar_portugal_iberian_workers_united.1.a
		hidden_effect = { add_timed_idea = { idea = POR_iberian_workers_united days = 730 } }
		effect_tooltip = {
			POR = { add_timed_idea = { idea = POR_iberian_workers_united days = 730 } }
			SPD = { add_timed_idea = { idea = POR_iberian_workers_united days = 730 } }
		}
	}
}

# Event for SPD when Portugal asks for annexation
country_event = {
	id = lar_portugal_iberian_workers_united.2
	title = lar_portugal_iberian_workers_united.2.t
	desc = lar_portugal_iberian_workers_united.2.desc
	picture = GFX_report_event_generic_communist_congress

	is_triggered_only = yes

	option = { # Accept
		name = lar_portugal_iberian_workers_united.2.a
		ai_chance = {
			base = 100
			modifier = {	# Not Stalinist - After Anarchist CW
				add = 15
				has_completed_focus = SPR_hinder_nkvd_interference
			}
		}

		trigger = {
			has_war = no
		}

		hidden_effect = {
			if = {
				limit = { 
					NOT = { has_global_flag = POR_iberian_union_successful_flag }
				}
				set_global_flag = POR_iberian_union_successful_flag
				POR = {	news_event = { id = lar_news.27 days = 3 random_days = 3 } }
			}
		}

		hidden_effect = {
			every_owned_state = {
				limit = {
					OR = {
						AND = {
							is_core_of = ROOT
							NOT = { is_core_of = FROM }
						}
						is_in_array = { SPR.game_start_core_states = THIS }
					}
				}
				add_core_of = FROM
			}
			FROM = {
				annex_country = {
				    target = ROOT
				    transfer_troops = yes
				}
			}
		}
		custom_effect_tooltip = lar_portugal_iberian_workers_united.2.a_tt
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { # Refuse
		name = lar_portugal_iberian_workers_united.2.b
		ai_chance = {
			base = 0
			modifier = {	# Democratic I
				add = 10
				has_completed_focus = SPR_maintain_the_second_republic
			}
			modifier = {	# Democratic II
				add = 5
				has_completed_focus = SPR_secure_democratic_principles
			}
			modifier = {	# Democratic III
				add = 5
				has_completed_focus = SPR_war_of_independence
			}
			modifier = {	# Stalinist I
				add = 10
				has_completed_focus = SPR_the_stalinist_doctrine
			}
			modifier = {	# Stalinist II
				add = 5
				has_completed_focus = SPR_appeal_for_increased_autonomy
			}
			modifier = { # Spanish Releasables will be reluctant to accept if they have different Ideology
				add = 100
				NOT = { tag = SPD }
				NOT = { has_government = ROOT }
			}
		}
		POR = {
			add_opinion_modifier = {
				target = ROOT
				modifier = POR_rejected_the_iberian_unification
			}
		}
	}
}


######## REFUSE NAVAL BLOCKADE ########
# Event for Major countries at war with ENG
country_event = {
	id = lar_portugal_naval_blockade.1
	title = lar_portugal_naval_blockade.1.t
	desc = lar_portugal_naval_blockade.1.desc
	picture = GFX_report_event_merchant_ship_01

	is_triggered_only = yes

	option = {
		name = lar_portugal_naval_blockade.1.a
		custom_effect_tooltip = lar_portugal_naval_blockade.1_tt
		every_country = {
			limit = { has_war_with = ENG }
			unlock_decision_tooltip = POR_evade_blockade_with_portuguese_convoys
		}
	}
}

# Event for POR when a Major country activates decision
country_event = {
	id = lar_portugal_naval_blockade.2
	title = lar_portugal_naval_blockade.2.t
	desc = lar_portugal_naval_blockade.2.desc
	picture = GFX_report_event_merchant_ship_01

	is_triggered_only = yes

	option = {
		name = lar_portugal_naval_blockade.2.a
		add_equipment_to_stockpile = {
            type = convoy_1
            amount = -50
        }
		add_offsite_building = { type = industrial_complex  level = 1 }
		FROM = {
			effect_tooltip = { add_war_support = 0.1 }
		}
	}
}

# Event for ENG when POR completes Refuse Naval Blockade focus
country_event = {
	id = lar_portugal_naval_blockade.3
	title = lar_portugal_naval_blockade.3.t
	desc = lar_portugal_naval_blockade.3.desc
	picture = GFX_report_event_merchant_ship_01

	is_triggered_only = yes

	option = {
		name = lar_portugal_naval_blockade.3.a
		custom_effect_tooltip = lar_portugal_naval_blockade.1_tt
		every_country = {
			limit = { has_war_with = ENG }
			unlock_decision_tooltip = POR_evade_blockade_with_portuguese_convoys
		}
		effect_tooltip = {
			remove_opinion_modifier = {
				target = POR
				modifier = POR_anglo_portuguese_alliance
			}
			POR= {
				remove_opinion_modifier = {
					target = ENG
					modifier = POR_anglo_portuguese_alliance
				}
			}
		}
	}
}


######## PURCHASE SHIPS FROM BRITAIN / ITALY ########
#Event for ENG/ITA to accept or reject Portuguese proposal to purchase ships
country_event = {
	id = lar_portugal_purchase_ships.1
	title = lar_portugal_purchase_ships.1.t
	desc = lar_portugal_purchase_ships.1.desc
	picture = GFX_report_event_sailors_in_working_rig

	is_triggered_only = yes

	option = { #Accept
		name = lar_portugal_purchase_ships.1.a

		ai_chance = {
			base = 99
			modifier = {
				factor = 0
				OR = {
					has_opinion = { target = POR value < 0 }
					has_civil_war = yes
					has_capitulated = yes
					has_war = yes
					AND = {
						tag = ENG
						NOT = { owns_state = 126 } #Owns London
					}
					AND = {
						tag = ITA
						NOT = { owns_state = 2 } #Owns Rome
					}
				}
			}
		}

		custom_effect_tooltip = lar_portugal_purchase_ships.1.a_tt
		POR = {
			country_event = { id = lar_portugal_purchase_ships.2 hours = 8 random_hours = 4 }
		}
	}
	option = { #Reject
		name = lar_portugal_purchase_ships.1.b

		ai_chance = {
			base = 1
		}

		POR = {
			country_event = { id = lar_portugal_purchase_ships.3 hours = 8 random_hours = 4 }
			if = {
				limit = { 
					ROOT = { tag = ENG }
				}
				set_country_flag = {
					flag = POR_british_ships_purchase_rejected_flag
					value = 1
					days = 180
				}
			}
			else_if = {
				limit = { 
					ROOT = { tag = ITA }
				}
				set_country_flag = {
					flag = POR_italian_ships_purchase_rejected_flag
					value = 1
					days = 180
				}
			}
		}
	}
}

# Event for POR to choose the type of ships to be purchased
country_event = {
	id = lar_portugal_purchase_ships.2
	title = lar_portugal_purchase_ships.2.t
	desc = lar_portugal_purchase_ships.2.desc
	picture = GFX_report_event_sailors_in_working_rig

	is_triggered_only = yes

	option = { # 3 Submarines - 1 Year
		name = lar_portugal_purchase_ships.2.a
		ai_chance = {
			base = 34
		}

		FROM = {
			add_offsite_building = {
				type = industrial_complex
				level = 1
			}
			add_opinion_modifier = {
				target = POR
				modifier = POR_bought_ships
			}
		}
		if = {
			limit = { FROM = { tag = ENG } }
			add_opinion_modifier = {
				target = ENG
				modifier = POR_sold_ships
			}
			add_opinion_modifier = {
				target = ENG
				modifier = POR_ships_trade
			}
			activate_decision = POR_british_submarines_construction_progress
			set_country_flag = POR_purchase_british_submarines_flag
		}
		else_if = {
			limit = { FROM = { tag = ITA } }
			add_opinion_modifier = {
				target = ITA
				modifier = POR_sold_ships
			}
			add_opinion_modifier = {
				target = ITA
				modifier = POR_ships_trade
			}
			activate_decision = POR_italian_submarines_construction_progress
			set_country_flag = POR_purchase_italian_submarines_flag
		}
	}
	option = { # 2 Destroyers - 2 Years
		name = lar_portugal_purchase_ships.2.b
		ai_chance = {
			base = 33
		}
		
		FROM = {
			add_offsite_building = {
				type = industrial_complex
				level = 1
			}
			add_opinion_modifier = {
				target = POR
				modifier = POR_bought_ships
			}
		}
		if = {
			limit = { FROM = { tag = ENG } }
			add_opinion_modifier = {
				target = ENG
				modifier = POR_sold_ships
			}
			add_opinion_modifier = {
				target = ENG
				modifier = POR_ships_trade
			}
			activate_decision = POR_british_destroyers_construction_progress
			set_country_flag = POR_purchase_british_destroyers_flag
		}
		else_if = {
			limit = { FROM = { tag = ITA } }
			add_opinion_modifier = {
				target = ITA
				modifier = POR_sold_ships
			}
			add_opinion_modifier = {
				target = ITA
				modifier = POR_ships_trade
			}
			activate_decision = POR_italian_destroyers_construction_progress
			set_country_flag = POR_purchase_italian_destroyers_flag
		}
	}
	option = { # 1 Light Cruiser - 3 Years
		name = lar_portugal_purchase_ships.2.c
		ai_chance = {
			base = 33
		}

		FROM = {
			add_offsite_building = {
				type = industrial_complex
				level = 1
			}
			add_opinion_modifier = {
				target = POR
				modifier = POR_bought_ships
			}
		}
		if = {
			limit = { FROM = { tag = ENG } }
			add_opinion_modifier = {
				target = ENG
				modifier = POR_sold_ships
			}
			add_opinion_modifier = {
				target = ENG
				modifier = POR_ships_trade
			}
			activate_decision = POR_british_light_cruiser_construction_progress
			set_country_flag = POR_purchase_british_light_cruiser_flag
		}
		else_if = {
			limit = { FROM = { tag = ITA } }
			add_opinion_modifier = {
				target = ITA
				modifier = POR_sold_ships
			}
			add_opinion_modifier = {
				target = ITA
				modifier = POR_ships_trade
			}
			activate_decision = POR_italian_light_cruiser_construction_progress
			set_country_flag = POR_purchase_italian_light_cruiser_flag
		}
	}
}

# Event for POR when ships purchase has been rejected
country_event = {
	id = lar_portugal_purchase_ships.3
	title = lar_portugal_purchase_ships.3.t
	desc = lar_portugal_purchase_ships.3.desc
	picture = GFX_report_event_generic_sign_treaty2

	is_triggered_only = yes

	option = {
		name = lar_portugal_purchase_ships.3.a
		clr_country_flag = POR_ships_purchase_in_progress_flag
	}
}

# Event for POR when submarines purchased are ready
country_event = {
	id = lar_portugal_purchase_ships.4
	title = lar_portugal_purchase_ships.4.t
	desc = lar_portugal_purchase_ships.4.desc
	picture = GFX_report_event_ast_navy

	is_triggered_only = yes

	option = {
		name = lar_portugal_purchase_ships.4.a
		custom_effect_tooltip = lar_portugal_purchase_ships.4.a_tt
	}
}

# Event for POR when destroyers purchased are ready
country_event = {
	id = lar_portugal_purchase_ships.5
	title = lar_portugal_purchase_ships.5.t
	desc = lar_portugal_purchase_ships.5.desc
	picture = GFX_report_event_ast_navy

	is_triggered_only = yes

	option = {
		name = lar_portugal_purchase_ships.5.a
		custom_effect_tooltip = lar_portugal_purchase_ships.5.a_tt
	}
}

# Event for POR when light cruiser purchased is ready
country_event = {
	id = lar_portugal_purchase_ships.6
	title = lar_portugal_purchase_ships.6.t
	desc = lar_portugal_purchase_ships.6.desc
	picture = GFX_report_event_ast_navy

	is_triggered_only = yes

	option = {
		name = lar_portugal_purchase_ships.6.a
		custom_effect_tooltip = lar_portugal_purchase_ships.6.a_tt
	}
}


######## PROMOTE MONARCHIST CAUSE ########
# Event for Brazil when Portugal activates "Promote Monarchist Cause in Brazil" Decision
country_event = {
	id = lar_portugal_promote_monarchist_cause.1
	title = lar_portugal_promote_monarchist_cause.1.t
	desc = lar_portugal_promote_monarchist_cause.1.desc
	picture = GFX_report_event_generic_rally

	is_triggered_only = yes

	option = {
		name = lar_portugal_promote_monarchist_cause.1.a
		unlock_decision_tooltip = POR_repress_brazilian_monarchists
	}
}

# Event for Brazil when Portugal completes "The Kingdom Reunited" Focus
country_event = {
	id = lar_portugal_promote_monarchist_cause.2
	title = lar_portugal_promote_monarchist_cause.2.t
	desc = lar_portugal_promote_monarchist_cause.2.desc
	picture = GFX_report_event_por_president_military_inspection

	is_triggered_only = yes

	option = { # Accept
		name = lar_portugal_promote_monarchist_cause.2.a
		ai_chance = {
			factor = 99
			modifier = { #Not non-aligned Brazil will never accept
				factor = 0
				NOT = { has_government = neutrality }
			}
		}
		
		hidden_effect = {
			POR = { news_event = { id = lar_news.26 days = 3 random_days = 5 } }
			every_state = {
				limit = { is_core_of = BRA }
				add_core_of  = POR
			}
		}
		POR = {
			country_event = lar_portugal_promote_monarchist_cause.5
			annex_country = { 
				target = ROOT
				transfer_troops = yes
			}
			hidden_effect = {
				set_cosmetic_tag = KPB_kingdom_portugal_and_brazil	
			}
		}
		custom_effect_tooltip = POR_kingdom_reunited_tooltip_tt
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { # Refuse
		name = lar_portugal_promote_monarchist_cause.2.b
		ai_chance = {
			factor = 1
			modifier = { # If POR helped during the CW, Monarchist BRA will be willing to accept
				factor = 0
				has_global_flag = POR_portugal_joined_brazilian_civil_war_flag
				has_government = neutrality
			}
		}
		POR = {
			create_wargoal = {
			  	target = ROOT
			    type = annex_everything
			}
			hidden_effect = { country_event = lar_portugal_promote_monarchist_cause.6 }
		}		
	}
}

# Event for Brazil when Portugal triggers the Monarchist Civil War
country_event = {
	id = lar_portugal_promote_monarchist_cause.3
	title = lar_portugal_promote_monarchist_cause.3.t

	desc = {
		text = lar_portugal_promote_monarchist_cause.3.desc #Pro-Monarchist
		trigger = {
			has_country_flag = POR_brazil_supports_monarchism_flag
		}
	}

	desc = {
		text = lar_portugal_promote_monarchist_cause.3.desc_anti_monarchist #Pro-Monarchist
		trigger = {
			NOT = { has_country_flag = POR_brazil_supports_monarchism_flag }
		}
	}

	picture = GFX_report_event_generic_rifles

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			if = { #BRA player is Monarchist
				limit = {
					has_country_flag = POR_brazil_supports_monarchism_flag
				}
				set_politics = {
					ruling_party = neutrality
				}
				add_popularity = { ideology = neutrality popularity = 0.5 }
				set_country_flag = EOB_empire_of_brazil_flag
				set_cosmetic_tag = EOB_empire_brazil_neutrality
				create_country_leader = {
					name = "Prince Pedro Henrique"
					desc = "POLITICS_PRINCE_PEDRO_HENRIQUE_DESC"
					picture = GFX_portrait_Prince_Pedro_Henrique
					expire = "1981.07.05"
					ideology = despotism
					traits = {
						inexperienced_monarch
					}					
				}
				set_temp_variable = { POR_bra_monarchist_cw_opposition = party_popularity@fascism }
				add_to_temp_variable = { POR_bra_monarchist_cw_opposition = party_popularity@communism }
				add_to_temp_variable = { POR_bra_monarchist_cw_opposition = party_popularity@democratic }
				start_civil_war = {
					ideology = fascism
					size = POR_bra_monarchist_cw_opposition
					capital = 501
					states = { 495 497 498 499 280 502 503 504 505 }
				}
				random_country = {
					limit = {
						original_tag = BRA
						has_government = fascism
					}
					POR = { 
						add_to_war = { targeted_alliance = BRA enemy = PREV hostility_reason = asked_to_join }
						hidden_effect = {
							diplomatic_relation = {
								country = BRA
								relation = military_access
								active = yes
							}
						}
					}
				}
				BRA = {
					set_party_name = { 
					    ideology = fascism
					    long_name = BRA_fascism_party_long
					    name = BRA_fascism_party
					}
					create_country_leader = {
						name = "Plínio Salgado"
						desc = "POLITICS_PLINIO_SALGADO_DESC"
						picture = GFX_portrait_Plinio_Salgado
						expire = "1965.1.1"
						ideology = fascism_ideology
						traits = {
							#
						}
					}
					effect_tooltip = {
						give_military_access = POR
					}
					hidden_effect = {
						diplomatic_relation = {
							country = POR
							relation = military_access
							active = yes
						}
					}
					add_opinion_modifier = {
						target = POR
						modifier = POR_helped_in_civil_war
					}
					set_global_flag = POR_portugal_joined_brazilian_civil_war_flag
				}
			}
			else = { #BRA player is Anti-Monarchist
				set_temp_variable = { POR_bra_monarchist_cw_opposition = party_popularity@neutrality }
				add_to_temp_variable = { POR_bra_monarchist_cw_opposition = party_popularity@communism }
				add_to_temp_variable = { POR_bra_monarchist_cw_opposition = party_popularity@democratic }
				start_civil_war = {
					ideology = neutrality
					size = POR_bra_monarchist_cw_opposition
					capital = 501
					states = { 495 497 280 502 503 504 505 }
				}
				if = {
					limit = {
						NOT = { has_government = fascism }
					}
					set_politics = {
						ruling_party = neutrality
					}
				}
				random_country = {
					limit = {
						original_tag = BRA
						has_government = neutrality
					}
					set_country_flag = EOB_empire_of_brazil_flag
					set_cosmetic_tag = EOB_empire_brazil_neutrality
					create_country_leader = {
						name = "Prince Pedro Henrique"
						desc = "POLITICS_PRINCE_PEDRO_HENRIQUE_DESC"
						picture = GFX_portrait_Prince_Pedro_Henrique
						expire = "1981.07.05"
						ideology = despotism
						traits = {
							inexperienced_monarch
						}					
					}
					create_country_leader = {
						name = "Plínio Salgado"
						desc = "POLITICS_PLINIO_SALGADO_DESC"
						picture = GFX_portrait_Plinio_Salgado
						expire = "1965.1.1"
						ideology = fascism_ideology
						traits = {
							#
						}
					}
					set_party_name = {
					    ideology = fascism
					    long_name = BRA_fascism_party_long
					    name = BRA_fascism_party
					}
					POR = { 
						add_to_war = { targeted_alliance = PREV enemy = BRA hostility_reason = asked_to_join }
						effect_tooltip = {
							give_military_access = PREV
						}
						hidden_effect = {
							diplomatic_relation = {
								country = PREV
								relation = military_access
								active = yes
							}
						}
					}
					effect_tooltip = {
						give_military_access = POR
					}
					hidden_effect = {
						diplomatic_relation = {
							country = POR
							relation = military_access
							active = yes
						}
					}
					add_opinion_modifier = {
						target = POR
						modifier = POR_helped_in_civil_war
					}
					set_global_flag = POR_portugal_joined_brazilian_civil_war_flag
				}
			}
		}
	}

	option = { #CW - BRA player is Monarchist
		name = lar_portugal_promote_monarchist_cause.3.a
		
		trigger = {
			has_country_flag = POR_brazil_supports_monarchism_flag
		}
		effect_tooltip = {
			set_politics = {
				ruling_party = neutrality
			}
			add_popularity = { ideology = neutrality popularity = 0.5 }
			set_country_flag = EOB_empire_of_brazil_flag
			set_cosmetic_tag = EOB_empire_brazil_neutrality
			create_country_leader = {
				name = "Prince Pedro Henrique"
				desc = "POLITICS_PRINCE_PEDRO_HENRIQUE_DESC"
				picture = GFX_portrait_Prince_Pedro_Henrique
				expire = "1981.07.05"
				ideology = despotism
				traits = {
					inexperienced_monarch
				}					
			}
			start_civil_war = {
				ideology = fascism
			}
			random_country = {
				limit = {
					original_tag = BRA
					has_government = fascism
				}
				POR = { 
					add_to_war = { targeted_alliance = BRA enemy = PREV hostility_reason = asked_to_join }
					give_military_access = BRA
				}
			}
			BRA = {
				give_military_access = POR
				add_opinion_modifier = {
					target = POR
					modifier = POR_helped_in_civil_war
				}
			}
		}
		custom_effect_tooltip = lar_portugal_promote_monarchist_cause.3.a_tt
	}

	option = { #CW - BRA is Fascist
		name = lar_portugal_promote_monarchist_cause.3.b
		
		trigger = {
			NOT = { has_country_flag = POR_brazil_supports_monarchism_flag }
		}
		
		effect_tooltip = {
			start_civil_war = {
				ideology = neutrality
			}
			if = {
				limit = {
					NOT = { has_government = fascism }
				}
				set_politics = {
					ruling_party = neutrality
				}
			}
			random_country = {
				limit = {
					original_tag = BRA
					has_government = neutrality
				}
				set_country_flag = EOB_empire_of_brazil_flag
				set_cosmetic_tag = EOB_empire_brazil_neutrality
				create_country_leader = {
					name = "Prince Pedro Henrique"
					desc = "POLITICS_PRINCE_PEDRO_HENRIQUE_DESC"
					picture = GFX_portrait_Prince_Pedro_Henrique
					expire = "1981.07.05"
					ideology = despotism
					traits = {
						inexperienced_monarch
					}					
				}
				POR = { 
					add_to_war = { targeted_alliance = PREV enemy = BRA hostility_reason = asked_to_join }
					give_military_access = PREV
				}
				give_military_access = POR
				add_opinion_modifier = {
					target = POR
					modifier = POR_helped_in_civil_war
				}
			}
		}
		custom_effect_tooltip = lar_portugal_promote_monarchist_cause.3.b_tt
	}
}

# Event for Brazil when Portugal completes "The Empire of Brazil" focus and changes Brazil's government peacefully
country_event = {
	id = lar_portugal_promote_monarchist_cause.4
	title = lar_portugal_promote_monarchist_cause.4.t
	desc = lar_portugal_promote_monarchist_cause.4.desc
	picture = GFX_report_event_por_return_of_the_monarchy

	is_triggered_only = yes

	option = {
		name = lar_portugal_promote_monarchist_cause.4.a
		
		add_stability = -0.2
		set_country_flag = EOB_empire_of_brazil_flag
		set_cosmetic_tag = EOB_empire_brazil_neutrality
		create_country_leader = {
			name = "Prince Pedro Henrique"
			desc = "POLITICS_PRINCE_PEDRO_HENRIQUE_DESC"
			picture = GFX_portrait_Prince_Pedro_Henrique
			expire = "1981.07.05"
			ideology = despotism
			traits = {
				inexperienced_monarch
			}					
		}
		if = {
			limit = { NOT = { has_government = neutrality } }
			set_politics = {
				ruling_party = neutrality
			}
			add_popularity = { ideology = neutrality popularity = 0.15 }
		}
		create_country_leader = {
			name = "Plínio Salgado"
			desc = "POLITICS_PLINIO_SALGADO_DESC"
			picture = GFX_portrait_Plinio_Salgado
			expire = "1965.1.1"
			ideology = fascism_ideology
			traits = {
				#
			}
		}
	}
}

# Event for Portugal when Brazil accepts to get annexed
country_event = {
	id = lar_portugal_promote_monarchist_cause.5
	title = lar_portugal_promote_monarchist_cause.5.t
	desc = lar_portugal_promote_monarchist_cause.5.desc
	picture = GFX_report_event_por_return_of_the_monarchy

	is_triggered_only = yes

	option = {
		name = lar_portugal_promote_monarchist_cause.5.a
	}
}

# Event for Portugal when Brazil refuses to get annexed
country_event = {
	id = lar_portugal_promote_monarchist_cause.6
	title = lar_portugal_promote_monarchist_cause.6.t
	desc = lar_portugal_promote_monarchist_cause.6.desc
	picture = GFX_report_event_por_return_of_the_monarchy

	is_triggered_only = yes

	option = {
		name = lar_portugal_promote_monarchist_cause.6.a
		effect_tooltip = {
			create_wargoal = {
			  	target = BRA
			    type = annex_everything
			}
		}
	}
}

# Event for BRA to decide if it will go Fascist or Monarchist
country_event = {
	id = lar_portugal_promote_monarchist_cause.7
	title = lar_portugal_promote_monarchist_cause.7.t
	desc = lar_portugal_promote_monarchist_cause.7.desc
	picture = GFX_report_event_generic_riot

	is_triggered_only = yes

	option = { #Support Monarchism
		name = lar_portugal_promote_monarchist_cause.7.a

		ai_chance = { #AI should always support Monarchism
			factor = 100
		}

		custom_effect_tooltip = lar_portugal_promote_monarchist_cause.7.a_tt
		hidden_effect = { set_country_flag = POR_brazil_supports_monarchism_flag }
		add_timed_idea = {
		    idea = POR_monarchists_on_the_rise
		    days = 730
		}
		set_party_name = { 
		    ideology = neutrality
		    long_name = BRA_monarchy_party_long
		    name = BRA_monarchy_party
		}
		set_party_name = { 
		    ideology = fascism
		    long_name = BRA_antimonarchist_coalition_long
		    name = BRA_antimonarchist_coalition
		}
		if = {
			limit = {
				OR = {
					has_government = neutrality
					has_government = democratic
					has_government = communism
				} 
			}
			set_politics = {
				ruling_party = fascism
			}
		}
		set_popularities = {
			democratic = 0
			neutrality = 20
			fascism = 80
			communism = 0
		}
		hidden_effect = { retire_country_leader = yes }
		BRA_getulio_vargas = {
			remove_country_leader_role = {
				ideology = despotism
			}
			add_country_leader_role = {
				country_leader = {
					expire = "1954.8.24"
					ideology = fascism_ideology
					traits = {
						anti_communist
					}
				}
				promote_leader = yes
			}
		}
		promote_character = BRA_arlindo_veiga_dos_santos
	}

	option = { #Support Anti-Monarchist Coalition
		name = lar_portugal_promote_monarchist_cause.7.b

		ai_chance = { #AI should never go Anti-Monarchist
			factor = 0
		}

		custom_effect_tooltip = lar_portugal_promote_monarchist_cause.7.b_tt
		hidden_effect = { set_country_flag = POR_brazil_supports_fascist_coalition_flag }
		add_timed_idea = {
		    idea = POR_monarchists_on_the_rise
		    days = 730
		}
		set_party_name = { 
		    ideology = neutrality
		    long_name = BRA_monarchy_party_long
		    name = BRA_monarchy_party
		}
		set_party_name = { 
		    ideology = fascism
		    long_name = BRA_antimonarchist_coalition_long
		    name = BRA_antimonarchist_coalition
		}
		if = {
			limit = {
				OR = {
					has_government = neutrality
					has_government = democratic
					has_government = communism
				} 
			}
			set_politics = {
				ruling_party = fascism
			}
		}
		set_popularities = {
			democratic = 0
			neutrality = 20
			fascism = 80
			communism = 0
		}
		hidden_effect = { retire_country_leader = yes }
		BRA_getulio_vargas = {
			remove_country_leader_role = {
				ideology = despotism
			}
			add_country_leader_role = {
				country_leader = {
					expire = "1954.8.24"
					ideology = fascism_ideology
					traits = {
						anti_communist
					}
				}
				promote_leader = yes
			}
		}
		promote_character = BRA_arlindo_veiga_dos_santos
	}
}


######## JOIN THE SPANISH CIVIL WAR ########
# Event for SPA, when Portugal completes focus "They Need our Help" 
country_event = {
	id = lar_portugal_spanish_civil_war.1
	title = lar_portugal_spanish_civil_war.1.t
	desc = lar_portugal_spanish_civil_war.1.desc
	picture = GFX_report_event_por_salazar_military

	is_triggered_only = yes

	option = {
		name = lar_portugal_spanish_civil_war.1.a
		POR = {
			unlock_decision_tooltip = POR_fight_alongside_the_republic
		}
		custom_effect_tooltip = lar_portugal_spanish_civil_war.1_tt
	}
}

# Event for SPD, when Portugal completes focus "Send Assistance" 
country_event = {
	id = lar_portugal_spanish_civil_war.2
	title = lar_portugal_spanish_civil_war.2.t
	desc = lar_portugal_spanish_civil_war.2.desc
	picture = GFX_report_event_por_salazar_franco2

	is_triggered_only = yes

	option = {
		name = lar_portugal_spanish_civil_war.2.a
		POR = {
			unlock_decision_tooltip = POR_fight_alongside_the_nationalists
		}
		custom_effect_tooltip = lar_portugal_spanish_civil_war.2_tt
	}
}

# Event for SPD & SPA, when Portugal completes focus "Support a Spanish Monarchy" 
country_event = {
	id = lar_portugal_spanish_civil_war.3
	title = lar_portugal_spanish_civil_war.3.t
	desc = lar_portugal_spanish_civil_war.3.desc
	picture = GFX_report_event_por_salazar_franco2

	is_triggered_only = yes

	option = {
		name = lar_portugal_spanish_civil_war.3.a
		POR = {
			unlock_decision_tooltip = POR_fight_alongside_the_carlists
		}
		custom_effect_tooltip = lar_portugal_spanish_civil_war.3_tt
	}
}

# Event for SPB, when Portugal completes focus "The Royal Iberian Alliance" and invites SPB to join faction 
country_event = {
	id = lar_portugal_royal_iberian_alliance.1
	title = lar_portugal_royal_iberian_alliance.1.t
	desc = lar_portugal_royal_iberian_alliance.1.desc
	picture = GFX_report_event_por_president_military_inspection

	is_triggered_only = yes

	option = { #Accept
		name = lar_portugal_royal_iberian_alliance.1.a

		ai_chance = {
			base = 60
			modifier = {
				factor = 0
				OR = {
					strength_ratio = { tag = FROM ratio > 2 }
					is_in_faction = yes
					has_war_with = FROM
				}
				
			}
			modifier = {
				factor = 0.5
				strength_ratio = { tag = FROM ratio > 1 }
			}
			modifier = {
				factor = 5
				has_opinion = { target = FROM value > 99 }
			}
		}

		POR = {
			create_faction = POR_royal_iberian_alliance
			add_to_faction = ROOT
		}
	}

	option = { #Refuse
		name = lar_portugal_royal_iberian_alliance.1.b

		ai_chance = {
			base = 40
			modifier = {
				factor = 0.2
				has_completed_focus = SPA_restore_the_iberian_union
			}
		}

		POR = {
			add_opinion_modifier = {
				target = ROOT
				modifier = POR_rejected_the_royal_iberian_alliance
			}
		}
	}
}


######## OVERSEAS PROVINCES ########
# Event for POR after integrating Angola (via decision)
country_event = {
	id = lar_portugal_overseas_provinces.1
	title = lar_portugal_overseas_provinces.1.t
	desc = lar_portugal_overseas_provinces.1.desc
	picture = GFX_report_event_por_estado_novo

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			if = {
				limit = { has_idea = POR_colonial_assimilation_policy }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy
	    			add_idea = POR_colonial_assimilation_policy_2
				}
			}
			else_if = {
				limit = { has_idea = POR_colonial_assimilation_policy_2 }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy_2
	    			add_idea = POR_colonial_assimilation_policy_3
				}
			}
		}
	}

	option = {
		name = lar_portugal_overseas_provinces.1.a
		add_stability = -0.1
		add_state_core = 540
		add_state_core = 796
		add_state_core = 892
		add_state_core = 891
		effect_tooltip = {
			if = { #Check for the idea added through immediate effect in order to show appropriate tt
				limit = { has_idea = POR_colonial_assimilation_policy_2 }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy
	    			add_idea = POR_colonial_assimilation_policy_2
				}
			}
			else_if = {
				limit = { has_idea = POR_colonial_assimilation_policy_3 }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy_2
	    			add_idea = POR_colonial_assimilation_policy_3
				}
			}
		}
	}
}

# Event for POR after integrating Mozambique (via decision) 
country_event = {
	id = lar_portugal_overseas_provinces.2
	title = lar_portugal_overseas_provinces.2.t
	desc = lar_portugal_overseas_provinces.2.desc
	picture = GFX_report_event_por_estado_novo

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			if = {
				limit = { has_idea = POR_colonial_assimilation_policy } 
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy
	    			add_idea = POR_colonial_assimilation_policy_2
				}
			}
			else_if = {
				limit = { has_idea = POR_colonial_assimilation_policy_2 }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy_2
	    			add_idea = POR_colonial_assimilation_policy_3
				}
			}
		}
	}

	option = {
		name = lar_portugal_overseas_provinces.2.a
		add_stability = -0.1
		add_state_core = 544
		add_state_core = 896
		add_state_core = 897
		effect_tooltip = {
			if = { #Check for the idea added through immediate effect in order to show appropriate tt
				limit = { has_idea = POR_colonial_assimilation_policy_2 }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy
	    			add_idea = POR_colonial_assimilation_policy_2
				}
			}
			else_if = {
				limit = { has_idea = POR_colonial_assimilation_policy_3 }
				swap_ideas = {
					remove_idea = POR_colonial_assimilation_policy_2
	    			add_idea = POR_colonial_assimilation_policy_3
				}
			}
		}
	}
}