###################################
########IBERIAN WARS EVENTS########
###################################

#Step 1 - The Basque Country revolts in Navarra and the Basque Country
#Step 2 - Portugal leaves the Union, former Portuguese colonies and islands (Azores, Madeira, Guinea-Bissau and Cabo Verde) go with it
#Step 3 - Guinea-Bissau begins revolting, gets demilitarized
#Step 4 - Guinea-Bissau declares independence
#Step 5 - Kaulza unsuccessfully coups the Estado Novo, GNS rises in the northern half of Portugal
#Step 6 - Morocco declares independence, Iberia can acknowledge it or try to reconquer it
#Step 7 - The Rif Republic rises up against Morocco
#Step 8 - Trarza crosses Morocco's southern border to reclaim Mauritania
#Step 9 - Fernando takes over Gibraltar and declares the protectorate
#Step 10 - With federal troops focused in the west and the north, Catalonia declares independence
#Step 11 - Galicia declares independence after the federales try to pass troops through the territory (the last stroke)
#Step 12 - Democrats and reformers within Iberia (aka as Spanish reformers and democrats because Portugal is gone) begin agitating in the South
#Step 13 - Democrats and reformers break free in the south, with their starting territory based on how strong their were before
#Step 14 - Falangists, ultrareactionaries and other far-right elements revolt in the north. Superevents trigger here, the Wars have officially begun
# -----------------------------WAR EXHAUSTION FACTIONS AND EVENTS-----------------------------
#the BTA will revolt in Asturias if Falangist Spain reaches 20% war exhaustion
#Falangist Spain will break into the NRF and Frente Azul if it reaches 70% war exhaustion
#The Spanish Republic will restore the monarchy if it reaches 35% war exhaustion
#The military will coup the Kingdom of Spain if it reaches 70% war exhaustion
#Andalucía will break away under the same conditions as above
#ETA will coup the Basque Country if it reaches 50% war exhaustion
#The People's Catalonian Army will rebel against the Catalonian government if it reaches 50% war exhaustion
#The Portuguese Provisional Republic will spawn in the southwest of Portugal when the GNS reaches 40% war exhaustion and controls the proper states
#The Portuguese People's Republic will spawn in the south of Portugal to the Provisional Republic if it reaches 40% war exhaustion and controls the relevant states
# -----------------------------PEACE EVENTS AND SIMILAR-----------------------------
#Salazarist Portugal, the Provisional and the People's Republic will peace out once it controls all of mainland Portugal
#GNS will temporarily peace out once it controls mainland Portugal, but will be forced to conquer all of Iberia shortly after
#The Federal Government and the NRF will peace out once they conquer the whole peninsula
#The Frente Azul will temporarily peace out once they conquer all of Spain, but will be forced to conquer Portugal shortly after
#Falangist Spain will peace out once it conquers all of Spain
#Republican Spain will peace out once it conquers all of Spain EXCEPT the existing regional factions
#Trarza will peace out once it conquers Mauritania
add_namespace = iberiawars

add_namespace = ibrwarexhaustion

add_namespace = ibrwarstages
####################################################################################################Faction spawning events
country_event = {#Basques fuck off
	id = iberiawars.1
	title = iberiawars.1.t
	desc = iberiawars.1.d
	picture = GFX_report_event_IBR_basque_protest
	is_triggered_only = yes
	fire_only_once = yes
	trigger = {
		NOT = { has_war_with = GER }
	}
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.1"
			set_global_flag = Iberian_Wars
			set_global_flag = IBW_happening
			GER = {
				if = {
					limit = {
						has_global_flag = german_civil_war_goeringvic
						has_completed_focus = GGR_fall_blau3
					}
					country_event = goering.blau.iberian_wars.1
					IBR = {
						remove_ideas = {
							GGR_against_the_german_giant
							GGR_against_the_german_giant_hard
						}
						delete_unit_template_and_units = { division_template = "GORING GOOD DIVISION INFANTRY" }
						delete_unit_template_and_units = { division_template = "GORING GOOD DIVISION ATTACK" }
						delete_unit_template_and_units = { division_template = "GORING GOOD DIVISION MOTORIZED" }
					}
				}
			}
			every_country = {
				if = {
					limit = {
						check_variable = { ECON_SPHERE_LEADER = IBR }
					}
					clr_country_flag = HAS_ECON_SPHERE
					clear_variable = ECON_SPHERE_LEADER
				}
			}
			if = {
				limit = {
					is_guaranteed_by = USA
				}
				USA = {
					diplomatic_relation = {
						country = IBR
						relation = guarantee
						active = no
					}
				}
			}
			if = {
				limit = {
					country_exists = SLG
				}
				SLG = {
					transfer_state = 459
					transfer_state = 1006
					transfer_state = 2118
					set_cosmetic_tag = SLG_FREE_YVES
				}
				end_puppet = SLG
			}
			if = {
				limit = {
					IBR = {
						has_war_with = SLG
					}
				}
				IBR = {
					white_peace = SLG
				}
				remove_mission = IBR_yves_war_mission
			}
			set_country_flag = IBR_caudillo_mechanic_over
			set_cosmetic_tag = IBR_WARS
			set_party_name = {
				ideology = despotism
				long_name = IBR_WARS_despotism_party_long
				name = IBR_WARS_despotism_party
			}
			set_politics = {
				ruling_party = despotism
				elections_allowed = no
			}
			promote_character = IBR_Francisco_Franco
			remove_country_leader_trait = strong_franco_trait
			remove_country_leader_trait = weak_franco_trait
			set_country_leader_description = {
				desc = "POLITICS_FRANCISCO_FRANCO_WARS_DESC"
			}
			IBR = {
				load_focus_tree = ZZZ_blank_focus
				IBR_remove_all_ideas = yes
				delete_unit = {}
				load_oob = Iberian_Wars_IBR
				remove_state_core = 984
				remove_state_core = 993
				add_ideas = {
					IBR_Alejandro_Valcarcel_hog
					IBR_Luis_Carrero_Blanco_sec
					IBR_Pedro_Cortina_for
					IBR_Gregorio_Bravo_eco
				}
			}
			IBRWarsGenerateTechStuff = yes
			set_country_flag = IBR_Iberian_Wars_have_happened
			IBR = { add_ideas = Iberian_Wars_Major }
			BSQ = { add_ideas = Iberian_Wars_Minor }
			ZZZ = {
				add_ideas = IBR_iberiawars_stage_one
				country_event = {
					id = ibrwarstages.1
					days = 120
				}
			}

			GER = {
				if = {
					limit = {
						has_global_flag = german_civil_war_goeringvic
						has_country_flag = GER_war_plan_B
					}
					GGR_Reload_main = yes
				}
			}

			# Create POR/SPA state arrays
			every_owned_state = {
				if = {
					limit = { is_portuguese_state = yes }
					add_to_array = { global.POR_state = THIS }
				}
				else_if = {
					limit = {
						is_spanish_state = yes
						NOT = { state = 1546 } #wars can end without naval invading morocco
					}
					add_to_array = { global.SPA_state = THIS }
				}
			}
		}
	}
	option = {#Play as Iberia
		name = iberiawars.1.a
		IBR = { country_event = { id = iberiawars.2 days = 3 } }
		BSQ = {
			transfer_state = 984
			transfer_state = 993
			add_state_core = 993
			add_state_core = 984
			hidden_effect = {
				load_oob = Iberian_Wars_BSQ
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_BSQ_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_BSQ_naval
				}
			}
		}

	}
	option = {#Play as Basques
		name = iberiawars.1.b
		trigger = { is_ai = no }
		IBR = { country_event = { id = iberiawars.2 days = 3 } }
		BSQ = {
			transfer_state = 984
			transfer_state = 993
			add_state_core = 993
			add_state_core = 984
			hidden_effect = {
				load_oob = Iberian_Wars_BSQ
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_BSQ_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_BSQ_naval
				}
			}
		}
		BSQ = {
			change_tag_from = IBR
		}
	}
}
country_event = {#Plan to invade Basque
	id = iberiawars.2
	title = iberiawars.2.t
	desc = iberiawars.2.d
	picture = GFX_report_event_IBR_iberian_wars_1
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			country_event = {
				id = iberiawars.3
				days = 5
			}
		}
	}
	option = {
		name = iberiawars.2.a
		start_border_war = {
			change_state_after_war = no
			attacker = {
				state = 994
				num_provinces = 2
				on_win = iberiawars.201
				on_lose = iberiawars.202
				on_cancel = iberiawars.203
			}
			defender = {
				state = 993
				num_provinces = 2
				on_win = iberiawars.204
				on_lose = iberiawars.205
				on_cancel = iberiawars.206
			}
		}
	}
	option = {
		name = iberiawars.2.b
		hidden_effect = {
			172 = { set_demilitarized_zone = no }
			993 = { set_demilitarized_zone = no }
		}
		start_border_war = {
			change_state_after_war = no
			attacker = {
				state = 985
				num_provinces = 3
				on_win = iberiawars.201
				on_lose = iberiawars.202
				on_cancel = iberiawars.203
			}
			defender = {
				state = 984
				num_provinces = 3
				on_win = iberiawars.204
				on_lose = iberiawars.205
				on_cancel = iberiawars.206
			}
		}
	}
}
country_event = {
	id = iberiawars.201
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.201" }
	title = iberiawars.201.t
	desc = iberiawars.201.d
	picture = GFX_report_event_IBR_iberian_wars_11

	is_triggered_only = yes
	hidden = yes

	option = {
		name = iberiawars.201.a
	}
}

country_event = {
	id = iberiawars.202
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.202" }
	title = iberiawars.202.t
	desc = iberiawars.202.d
	picture = GFX_report_event_IBR_iberian_wars_11

	is_triggered_only = yes
	hidden = yes

	option = {
		name = iberiawars.202.a
	}
}

country_event = {
	id = iberiawars.203
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.203" }
	title = iberiawars.203.t
	desc = iberiawars.203.d
	picture = GFX_report_event_IBR_iberian_wars_11

	is_triggered_only = yes
	hidden = yes

	option = {
		name = iberiawars.203.a
	}
}

country_event = {
	id = iberiawars.204
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.204" }
	title = iberiawars.204.t
	desc = iberiawars.204.d
	picture = GFX_report_event_IBR_iberian_wars_11

	is_triggered_only = yes
	hidden = yes

	option = {
		name = iberiawars.204.a
	}
}

country_event = {
	id = iberiawars.205
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.205" }
	title = iberiawars.205.t
	desc = iberiawars.205.d
	picture = GFX_report_event_IBR_iberian_wars_11

	is_triggered_only = yes
	hidden = yes

	option = {
		name = iberiawars.205.a
	}
}

country_event = {
	id = iberiawars.206
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.206" }
	title = iberiawars.206.t
	desc = iberiawars.206.d
	picture = GFX_report_event_IBR_iberian_wars_11

	is_triggered_only = yes
	hidden = yes

	option = {
		name = iberiawars.206.a
	}
}
country_event = {#Portugal fucks off
	id = iberiawars.3
	title = iberiawars.3.t
	desc = iberiawars.3.d
	picture = GFX_report_event_IBR_portuguese_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.3"
		hidden_effect = {

			if = {
				limit = {
					IBR = {
						has_character = IBR_Antonio_Salazar
					}
				}
				IBR_Antonio_Salazar = {
					set_nationality = POR
				}
				POR = {
					promote_character = IBR_Antonio_Salazar
				}
			}
			else = {
				IBR_Marcelo_Caetano = {
					set_nationality = POR
				}
				POR = {
					add_country_leader_role = {
						character = IBR_Marcelo_Caetano
						promote_leader = yes
						country_leader = {
							ideology = despotism_civilian_dictatorship_subtype
							expire = "1981.10.20"
						}
					}
				}
			}
			every_unit_leader = {
				limit = { has_id = 1306 }
				set_nationality = POR

			}
			every_unit_leader = {
				limit = { has_id = 1307 }
				set_nationality = RPP

			}
			every_unit_leader = {
				limit = { has_id = 1309 }
				set_nationality = POR

			}
			every_unit_leader = {
				limit = { has_id = 1314 }
				set_nationality = POR

			}
			every_unit_leader = {
				limit = { has_id = 1315 }
				set_nationality = POR
			}
			POR = {
				add_ideas = {
					Iberian_Wars_Major
					POR_surrender_shit
				}
			}
			every_state = {
				limit = {
					is_portuguese_state = yes
				}
				POR = {
					transfer_state = PREV
					add_state_claim = PREV
				}
				IBR = {
					remove_state_core = PREV
				}
			}
			POR = {
				transfer_state = 296
				transfer_state = 702
				add_state_core = 112
				add_state_core = 179
				add_state_core = 1004
				add_state_core = 1000
				add_state_core = 697
				add_state_core = 698
				add_state_core = 1672
				add_state_core = 1673
				add_state_core = 1674
				country_event = { id = iberiawars.301 days = 3 }
			}
			IBR = {
				if = {
					limit = {
						GAB = {
							exists = yes
						}
					}
					country_event = {
						id = A_SPRING.1
						days = 3
					}
				}
				else = {
					country_event = {
						id = A_SPRING.1
						days = 10
					}
				}
				country_event = {
					id = A_SPRING.2
					days = 5
				}
			}
		}
	}
	option = {#Play as Iberia
		name = iberiawars.3.a
		hidden_effect = {
			POR = {
				load_oob = Iberian_Wars_POR
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_POR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_POR_naval
				}
			}
		}
		IBR = {
			hidden_effect = {
				country_event = {
					id = iberiawars.5
					days = 5
				}
			}
		}
	}
	option = {#Play as Portugal
		name = iberiawars.3.b
		trigger = { is_ai = no }
		hidden_effect = {
			POR = {
				load_oob = Iberian_Wars_POR
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_POR_naval_mtg

				}
				else = {
					load_oob = Iberian_Wars_POR_naval_mtg
				}
			}
		}
		POR = {
			change_tag_from = IBR
		}
		IBR = {
			hidden_effect = {
				country_event = {
					id = iberiawars.5
					days = 5
				}
			}
		}
	}
}
country_event = {#Guinea gets demilitarized
	id = iberiawars.301
	title = iberiawars.301.t
	desc = iberiawars.301.d
	picture = GFX_report_event_GRO_african_rebels2
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.301"
	}
	option = {
		name = iberiawars.301.a
		add_political_power = -20
		add_stability = -0.2
		296 = {
			set_demilitarized_zone = yes
		}
		hidden_effect = {
			country_event = {
				id = iberiawars.302
				days = 2
			}
		}
	}
}

country_event = {#Guinea gets independence
	id = iberiawars.302
	title = iberiawars.302.t
	desc = iberiawars.302.d
	picture = GFX_report_event_IBR_guinea_soldiers_plane_wreckage
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.302"
	}
	option = {
		name = iberiawars.302.a
		296 = {
			set_demilitarized_zone = no
		}
		add_stability = -0.35
		GNB = {
			add_state_core = 296
			add_state_core = 702
			transfer_state = 296
			transfer_state = 702
		}
		hidden_effect = {
			180 = {
				set_demilitarized_zone = yes
			}
			181 = {
				set_demilitarized_zone = yes
			}
			997 = {
				set_demilitarized_zone = yes
			}
			998 = {
				set_demilitarized_zone = yes
			}
			country_event = {
				id = iberiawars.4
				days = 3
			}
		}
	}
}
country_event = {#GNS Rises Up
	id = iberiawars.4
	title = iberiawars.4.t
	desc = iberiawars.4.d
	picture = GFX_report_event_IBR_iberian_wars_gns_1
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.4"
			GNS = {
				add_ideas = Iberian_Wars_Major
				IBRWarsAddPORclaims = yes
			}
			180 = {
				set_demilitarized_zone = no
			}
			181 = {
				set_demilitarized_zone = no
			}
			997 = {
				set_demilitarized_zone = no
			}
			998 = {
				set_demilitarized_zone = no
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.10
					days = 3
				}
			}
		}
	}
	option = {#Play as Portugal
		name = iberiawars.4.a
		GNS = {
			transfer_state = 180
			transfer_state = 181
			transfer_state = 997
			transfer_state = 998
			add_state_core = 180
			add_state_core = 181
			add_state_core = 997
			add_state_core = 998
		}

		GNS = {
			hidden_effect = {
				load_oob = Iberian_Wars_GNS
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_GNS_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_GNS_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_POR
						}
					}
					POR = {
						apply_war_buff_with_5_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_GNS
						}
					}
					apply_war_buff_with_5_divisions = yes
				}
			}
			declare_war_on = {
				target = POR
				type = civil_war
			}
		}
	}
	option = {#Play as GNS
		name = iberiawars.4.b
		trigger = { is_ai = no }

		GNS = {
			transfer_state = 180
			transfer_state = 181
			transfer_state = 997
			transfer_state = 998
			add_state_core = 180
			add_state_core = 181
			add_state_core = 997
			add_state_core = 998
		}
		GNS = {
			hidden_effect = {
				load_oob = Iberian_Wars_GNS
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_GNS_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_GNS_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_POR
						}
					}
					POR = {
						apply_war_buff_with_5_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_GNS
						}
					}
					apply_war_buff_with_5_divisions = yes
				}
			}
			declare_war_on = {
				target = POR
				type = civil_war
			}
		}
		GNS = {
			change_tag_from = POR
		}
	}
}
country_event = {#Morocco Demands Freedom
	id = iberiawars.5
	title = iberiawars.5.t
	desc = iberiawars.5.d
	picture = GFX_report_event_IBR_king_hassan
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.4"
			every_unit_leader = {
				limit = { has_id = 1304 }
				set_nationality = MOR
			}
			MOR = { add_ideas = Iberian_Wars_Major }
			MOR = {
				transfer_state = 461
				transfer_state = 462
				transfer_state = 1152
				transfer_state = 1153
				transfer_state = 1008
				transfer_state = 1009
				transfer_state = 1005
				transfer_state = 1150
				transfer_state = 699
				transfer_state = 1010
				transfer_state = 1011
				transfer_state = 1155
				transfer_state = 1156
				transfer_state = 1158
				transfer_state = 1151
				transfer_state = 1612
				transfer_state = 2112
				transfer_state = 2113
				transfer_state = 2114
				transfer_state = 2115
				transfer_state = 2116
				add_state_core = 1005
				add_state_core = 1150
				add_state_core = 461
				add_state_core = 1153
				add_state_core = 1152
				add_state_core = 462
				add_state_core = 1008
				add_state_core = 1009
				add_state_core = 1151
				add_state_core = 2115
				add_state_core = 2116
			}
			IBRWarsAddMORclaims = yes
		}
	}
	option = {#Give it to them so they cooperate (Play as Iberia)
		name = iberiawars.5.a
		hidden_effect = {
			MOR = {
				load_oob = Iberian_Wars_MOR
			}
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.501
					days = 1
				}
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.6
					days = 2
				}
			}
		}
	}
	option = {#Give it to them so they cooperate (Play as Morocco)
		name = iberiawars.5.b
		trigger = { is_ai = no }
		hidden_effect = {
			MOR = {
				load_oob = Iberian_Wars_MOR
			}
		}
		MOR = {
			change_tag_from = IBR
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.501
					days = 1
				}
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.6
					days = 2
				}
			}
		}
	}
	option = {#Go to war with them (Play as Iberia)
		name = iberiawars.5.c
		hidden_effect = {
			MOR = {
				load_oob = Iberian_Wars_MOR
			}
		}
		hidden_effect = { MOR = {
				country_event = {
					id = iberiawars.502
					days = 1
				}
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.6
					days = 2
				}
			}
		}
	}
	option = {#Go to war with them (Play as Morocco)
		name = iberiawars.5.e
		trigger = { is_ai = no }
		hidden_effect = {
			MOR = {
				load_oob = Iberian_Wars_MOR
			}
		}
		MOR = {
			change_tag_from = IBR
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.502
					days = 1
				}
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.6
					days = 2
				}
			}
		}
	}
}
country_event = {#Morocco Demands Freedom - Yes
	id = iberiawars.501
	title = iberiawars.501.t
	desc = iberiawars.501.d
	picture = GFX_report_event_IBR_meeting_table
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.501"
		}
	}
	option = {#Give it to them so they cooperate
		name = iberiawars.501.a
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.5011
					days = 2
				}
			}
		}
	}
}

country_event = {#Morocco Demands Freedom - Yes - Rif Republic spawns
	id = iberiawars.5011
	title = iberiawars.5011.t
	desc = iberiawars.5011.d
	picture = GFX_report_event_ALG_algerian_war
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.5011"
			RIF = {
				add_state_core = 1005
				add_state_core = 1546
				transfer_state = 1005
				transfer_state = 1546
				add_ideas = Iberian_Wars_Major
			}
			IBRWarsAddRIFclaims = yes
		}
	}
	option = {
		name = iberiawars.5011.a
		hidden_effect = {
			RIF = {
				load_oob = Iberian_Wars_RIF
			}
		}
		MOR = {
			declare_war_on = {
				target = RIF
				type = annex_everything
			}
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.5012
					days = 3
				}
			}
		}
	}
	option = {
		name = iberiawars.5011.b
		trigger = { is_ai = no }
		RIF = {
			hidden_effect = {
				load_oob = Iberian_Wars_RIF
			}
			change_tag_from = MOR
		}
		MOR = {
			declare_war_on = {
				target = RIF
				type = annex_everything
			}
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.5012
					days = 3
				}
			}
		}
	}
}

country_event = {#Morocco Demands Freedom - Yes - WAIR spawns
	id = iberiawars.5012
	title = iberiawars.5012.t
	desc = iberiawars.5012.d
	picture = GFX_report_event_ALG_native_surrender
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.5012"
			TRZ = {
				add_state_core = 1009
				add_state_core = 1010
				add_state_core = 1011
				add_state_core = 1155
				add_state_core = 1156
				add_state_core = 1158
				add_state_core = 2115
				add_state_core = 2116
				transfer_state = 1009
				transfer_state = 1010
				transfer_state = 1011
				transfer_state = 1155
				transfer_state = 1156
				transfer_state = 1158
				transfer_state = 2115
				transfer_state = 2116
			}
			IBRWarsAddTRZclaims = yes
		}
	}
	option = {
		name = iberiawars.5012.a
		hidden_effect = {
			TRZ = {
				load_oob = Iberian_Wars_TRZ
			}
		}
		MOR = {
			declare_war_on = {
				target = TRZ
				type = annex_everything
			}
		}
	}
	option = {
		name = iberiawars.5012.b
		trigger = { is_ai = no }
		TRZ = {
			hidden_effect = {
				load_oob = Iberian_Wars_TRZ
			}
			change_tag_from = MOR
		}
		MOR = {
			declare_war_on = {
				target = TRZ
				type = annex_everything
			}
		}
	}
}

country_event = {#Morocco Demands Freedom - No
	id = iberiawars.502
	title = iberiawars.502.t
	desc = iberiawars.502.d
	picture = GFX_report_event_ALG_algerian_war
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.502"
		}
	}
	option = {
		name = iberiawars.502.a
		IBR = {
			declare_war_on = {
				target = MOR
				type = puppet_wargoal_focus
			}
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.5021
					days = 7
				}
			}
		}
	}
}

country_event = {#Morocco Demands Freedom - No - WAIR spawns
	id = iberiawars.5021
	title = iberiawars.5021.t
	desc = iberiawars.5021.d
	picture = GFX_report_event_ALG_native_surrender
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.5021"
			TRZ = {
				add_state_core = 1009
				add_state_core = 1010
				add_state_core = 1011
				add_state_core = 1155
				add_state_core = 1156
				add_state_core = 1158
				add_state_core = 2115
				add_state_core = 2116
				transfer_state = 1009
				transfer_state = 1010
				transfer_state = 1011
				transfer_state = 1155
				transfer_state = 1156
				transfer_state = 1158
				transfer_state = 2115
				transfer_state = 2116
			}
			IBRWarsAddTRZclaims = yes
		}
	}
	option = {
		name = iberiawars.5021.a
		hidden_effect = {
			TRZ = {
				load_oob = Iberian_Wars_TRZ
			}
		}
		MOR = {
			declare_war_on = {
				target = TRZ
				type = annex_everything
			}
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.5022
					days = 3
				}
			}
		}
	}
	option = {
		name = iberiawars.5021.b
		trigger = { is_ai = no }
		TRZ = {
			hidden_effect = {
				load_oob = Iberian_Wars_TRZ
			}
			change_tag_from = MOR
		}
		hidden_effect = {
			MOR = {
				country_event = {
					id = iberiawars.5022
					days = 3
				}
			}
		}
		MOR = {
			declare_war_on = {
				target = TRZ
				type = annex_everything
			}
		}
	}
}
country_event = {#Morocco Demands Freedom - No - Rif Republic spawns
	id = iberiawars.5022
	title = iberiawars.5022.t
	desc = iberiawars.5022.d
	picture = GFX_report_event_ALG_algerian_war
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			log = "[GetDateText]: [Root.GetName]: event iberiawars.5022"
			RIF = {
				add_state_core = 1005
				add_state_core = 1546
				transfer_state = 1005
				transfer_state = 1546
				add_ideas = Iberian_Wars_Major
			}
			IBRWarsAddRIFclaims = yes
		}
	}
	option = {
		name = iberiawars.5022.a
		hidden_effect = {
			RIF = {
				load_oob = Iberian_Wars_RIF
			}
		}
		MOR = {
			declare_war_on = {
				target = RIF
				type = annex_everything
			}
		}
	}
	option = {
		name = iberiawars.5022.b
		trigger = { is_ai = no }
		RIF = {
			hidden_effect = {
				load_oob = Iberian_Wars_RIF
			}
			change_tag_from = MOR
		}
		MOR = {
			declare_war_on = {
				target = RIF
				type = annex_everything
			}
		}
	}
}
country_event = {#Catalonia Splits
	id = iberiawars.6
	title = iberiawars.6.t
	desc = iberiawars.6.d
	picture = GFX_report_event_IBR_catalonia_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.6"
		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1311 }
				set_nationality = CTL

			}
			IBRWarsAddCTLclaims = yes
			CTL = { add_ideas = Iberian_Wars_Minor }
			CTL = {
				transfer_state = 165
				transfer_state = 1012
				transfer_state = 986
				add_state_core = 165
				add_state_core = 1012
				add_state_core = 986
			}
			IBR = {
				remove_state_core = 165
				remove_state_core = 1012
				remove_state_core = 986
			}
		}
	}
	option = {#Play as Iberia
		name = iberiawars.6.a

		hidden_effect = {
			CTL = {
				load_oob = Iberian_Wars_CTL
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_CTL_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_CTL_naval
				}
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.7
					days = 2
				}
			}
		}
	}
	option = {#Play as Catalonia
		name = iberiawars.6.b
		trigger = { is_ai = no }

		hidden_effect = {
			CTL = {
				load_oob = Iberian_Wars_CTL
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_CTL_naval
				}
				else = {
					load_oob = Iberian_Wars_CTL_naval
				}
			}
		}
		CTL = {
			change_tag_from = IBR
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.7
					days = 2
				}
			}
		}
	}
}

country_event = {#Galicia Splits
	id = iberiawars.7
	title = iberiawars.7.t
	desc = iberiawars.7.d
	picture = GFX_report_event_IBR_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.7"
		hidden_effect = {
			GAL = { add_ideas = Iberian_Wars_Minor }
			GAL = {
				add_state_core = 982
				add_state_core = 171
				transfer_state = 982
				transfer_state = 171
			}
			IBR = {
				remove_state_core = 982
				remove_state_core = 171
			}
		}
		hidden_effect = {
			IBR = {
				country_event = {
					id = iberiawars.8
					days = 2
				}
			}
		}
	}
	option = {#Play as Iberia
		name = iberiawars.7.a

		hidden_effect = {
			GAL = {
				load_oob = Iberian_Wars_GAL
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_GAL_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_GAL_naval
				}
			}
		}
	}
	option = {#Play as Galicia
		name = iberiawars.7.b
		trigger = { is_ai = no }

		hidden_effect = {
			GAL = {
				load_oob = Iberian_Wars_GAL
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_GAL_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_GAL_naval
				}
			}
		}
		GAL = {
			change_tag_from = IBR
		}

	}
}

country_event = {#Republican Unrest
	id = iberiawars.8
	title = iberiawars.8.t
	desc = iberiawars.8.d
	picture = GFX_report_event_ORE_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.8"
	}
	option = {#Play as Iberia
		name = iberiawars.8.a
		hidden_effect = {
			country_event = { id = iberiawars.9 days = 5 }
			set_temp_variable = { IBRWarsDemSupport = 0 }
			add_to_temp_variable = { IBRWarsDemSupport = IBR.IBRIRMUDPopularity }
			add_to_temp_variable = { IBRWarsDemSupport = IBR.IBRAlianzaPopularPopularity }
			add_to_temp_variable = { IBRWarsDemSupport = IBR.IBRMarketLiberalPopularity }
			add_to_temp_variable = { IBRWarsDemSupport = IBR.IBRIzquierdaPopularity }
			if = {
				limit = {
					check_variable = { IBRWarsDemSupport > 315 }
				}
				country_event = { id = iberiawars.807 days = 2 }
			}
			else_if = {
				limit = {
					check_variable = { IBRWarsDemSupport > 270 }
				}
				country_event = { id = iberiawars.806 days = 2 }
			}
			else_if = {
				limit = {
					check_variable = { IBRWarsDemSupport > 225 }
				}
				country_event = { id = iberiawars.805 days = 2 }
			}
			else_if = {
				limit = {
					check_variable = { IBRWarsDemSupport > 180 }
				}
				country_event = { id = iberiawars.804 days = 2 }
			}
			else_if = {
				limit = {
					check_variable = { IBRWarsDemSupport > 135 }
				}
				country_event = { id = iberiawars.803 days = 2 }
			}
			else_if = {
				limit = {
					check_variable = { IBRWarsDemSupport > 90 }
				}
				country_event = { id = iberiawars.802 days = 2 }
			}
			else = {
				country_event = { id = iberiawars.801 days = 2 }
			}
		}
		add_political_power = -50
	}
}
country_event = {#Republic Splits
	id = iberiawars.801
	title = iberiawars.801.t
	desc = iberiawars.801.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.801"
		hidden_effect = {
			every_unit_leader = {
				limit = {
					has_id = 1312
					has_id = 9361
					has_id = 9747
				}
				set_nationality = SPR

			}
			SPR = { add_ideas = Iberian_Wars_Major }
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
			}
			SPR = {
				transfer_state = 173
				transfer_state = 169
				add_state_core = 173
				add_state_core = 169
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.801.a
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_1
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.801.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_1
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
		}
		SPR = {
			change_tag_from = ROOT
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}

	}
}

country_event = {#Republic Splits
	id = iberiawars.802
	title = iberiawars.802.t
	desc = iberiawars.802.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.802"
		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1312 }
				set_nationality = SPR

			}
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
				remove_state_core = 1003
			}
			SPR = { add_ideas = Iberian_Wars_Major }
			SPR = {
				transfer_state = 173
				transfer_state = 1003
				transfer_state = 169
				add_state_core = 173
				add_state_core = 169
				add_state_core = 1003
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.802.a

		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_2
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.802.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_2
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
		SPR = {
			change_tag_from = ROOT

		}
	}
}

country_event = {#Republic Splits
	id = iberiawars.803
	title = iberiawars.803.t
	desc = iberiawars.803.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.803"

		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1312 }
				set_nationality = SPR

			}
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
				remove_state_core = 1003
				remove_state_core = 168
			}
			SPR = { add_ideas = Iberian_Wars_Major }
			SPR = {
				transfer_state = 173
				transfer_state = 1003
				transfer_state = 168
				transfer_state = 169
				add_state_core = 173
				add_state_core = 169
				add_state_core = 1003
				add_state_core = 168
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.803.a
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_3
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.803.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_3
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
		SPR = {
			change_tag_from = ROOT
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
}

country_event = {#Republic Splits
	id = iberiawars.804
	title = iberiawars.804.t
	desc = iberiawars.804.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.804"
		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1312 }
				set_nationality = SPR

			}
			SPR = { add_ideas = Iberian_Wars_Major }
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
				remove_state_core = 1003
				remove_state_core = 168
				remove_state_core = 167
			}
			SPR = {
				transfer_state = 173
				transfer_state = 1003
				transfer_state = 168
				transfer_state = 169
				transfer_state = 167
				add_state_core = 173
				add_state_core = 1003
				add_state_core = 168
				add_state_core = 169
				add_state_core = 167
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.804.a
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_4
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.804.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {

				load_oob = Iberian_Wars_SPR_4
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
		SPR = {
			change_tag_from = ROOT
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}

	}
}

country_event = {#Republic Splits
	id = iberiawars.805
	title = iberiawars.805.t
	desc = iberiawars.805.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.805"
		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1312 }
				set_nationality = SPR

			}
			SPR = { add_ideas = Iberian_Wars_Major }
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
				remove_state_core = 1003
				remove_state_core = 168
				remove_state_core = 167
				remove_state_core = 988
			}
			SPR = {
				transfer_state = 173
				transfer_state = 1003
				transfer_state = 168
				transfer_state = 169
				transfer_state = 167
				transfer_state = 988
				add_state_core = 173
				add_state_core = 169
				add_state_core = 1003
				add_state_core = 168
				add_state_core = 167
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.805.a
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_5
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.805.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_5
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
		SPR = {
			change_tag_from = ROOT
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
}

country_event = {#Republic Splits
	id = iberiawars.806
	title = iberiawars.806.t
	desc = iberiawars.806.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.806"
		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1312 }
				set_nationality = SPR

			}
			SPR = { add_ideas = Iberian_Wars_Major }
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
				remove_state_core = 1003
				remove_state_core = 168
				remove_state_core = 167
				remove_state_core = 988
				remove_state_core = 1001
			}
			SPR = {
				transfer_state = 173
				transfer_state = 1003
				transfer_state = 168
				transfer_state = 169
				transfer_state = 167
				transfer_state = 988
				transfer_state = 1001
				add_state_core = 173
				add_state_core = 169
				add_state_core = 1003
				add_state_core = 168
				add_state_core = 167
				add_state_core = 988
				add_state_core = 1001
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.806.a
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_6
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.806.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_6
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
		SPR = {
			change_tag_from = ROOT
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
}

country_event = {#Republic Splits
	id = iberiawars.807
	title = iberiawars.807.t
	desc = iberiawars.807.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.807"
		hidden_effect = {
			every_unit_leader = {
				limit = { has_id = 1312 }
				set_nationality = SPR

			}
			SPR = { add_ideas = Iberian_Wars_Major }
			IBR = {
				remove_state_core = 173
				remove_state_core = 169
				remove_state_core = 1003
				remove_state_core = 168
				remove_state_core = 167
				remove_state_core = 988
				remove_state_core = 1001
				remove_state_core = 1002
			}
			SPR = {
				transfer_state = 173
				transfer_state = 1003
				transfer_state = 168
				transfer_state = 169
				transfer_state = 167
				transfer_state = 988
				transfer_state = 1001
				transfer_state = 1002
				add_state_core = 173
				add_state_core = 169
				add_state_core = 1003
				add_state_core = 168
				add_state_core = 167
				add_state_core = 988
				add_state_core = 1001
				add_state_core = 1002
			}
			IBRWarsAddSPRclaims = yes
		}
	}
	option = {#Play as Iberia
		name = iberiawars.807.a
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_7
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
		}
	}
	option = {#Play as Republic
		name = iberiawars.807.b
		trigger = { is_ai = no }
		SPR = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPR_7
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPR_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPR_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_IBR
						}
					}
					IBR = {
						apply_war_buff_with_10_divisions = yes
					}
				}
				else_if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPR
						}
					}
					add_ideas = Custom_TNO_war_buff
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}

		}
		SPR = {
			change_tag_from = ROOT
		}

	}
}

country_event = {#Falange Splits
	id = iberiawars.9
	title = iberiawars.9.t
	desc = iberiawars.9.d
	picture = GFX_report_event_IBR_falange_rally
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.9"
		hidden_effect = {
			IBR = { remove_ideas = PAR_condor_legion }
			if = {
				limit = {
					ITA = {
						has_country_leader = {
							character = ITA_Carlo_Scorza
							ruling_only = yes
						}
					}
				}
				ITA = {
					country_event = {
						id = IBR.3157
						days = 1
					}
				}
			}
			every_country = {
				limit = { has_idea = PAR_condor_legion }
				set_temp_variable = { target = SPS }
				TNO_increase_volunteer_cap_3 = yes
			}
			SPS = { add_ideas = PAR_condor_legion }
			every_unit_leader = {
				limit = { has_id = 1319 }
				set_nationality = FZL

			}
			every_unit_leader = {
				limit = { has_id = 1305 }
				set_nationality = SPS

			}
			every_unit_leader = {
				limit = { has_id = 1308 }
				set_nationality = SPS

			}
			set_global_flag = Iberian_Anarchy_flag
			SPS = { add_ideas = Iberian_Wars_Major }
			IBR = {
				IBRWarsAddIBRclaims = yes
				remove_state_core = 174
				remove_state_core = 995
				remove_state_core = 994
				remove_state_core = 996
				remove_state_core = 983
				remove_state_core = 172
				remove_state_core = 176
			}
			SPS = {
				IBRWarsAddSPSclaims = yes
				transfer_state = 174
				transfer_state = 995
				transfer_state = 994
				transfer_state = 996
				transfer_state = 983
				transfer_state = 172
				transfer_state = 176
				add_state_core = 174
				add_state_core = 995
				add_state_core = 994
				add_state_core = 996
				add_state_core = 983
				add_state_core = 176
				add_state_core = 172
				if = {
					limit = {
						NOT = { SPR = { owns_state = 166 }	}
					}
					transfer_state = 166
					add_state_core = 166
				}
				if = {
					limit = {
						NOT = { SPR = { owns_state = 985 }	}
					}
					transfer_state = 985
					add_state_core = 985
				}
			}
		}
	}
	option = {#Play as Iberia
		name = iberiawars.9.a
		SPS = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPS
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPS_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPS_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPS
						}
					}
					apply_war_buff_with_10_divisions = yes
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
			declare_war_on = {
				target = SPR
				type = annex_everything
			}
		}
		every_country = {
			limit = { is_ai = no }
			set_temp_variable = { TNO_temp_super_event = token:SE_IBERIAN_WARS }
			TNO_fire_super_event = yes
		}
		set_global_flag = IBW_CONFLICT
		hidden_effect = {
			if = {
				limit = {
					NOT = { has_global_flag = german_civil_war_heydrichvic }
				}
				GER = {
					country_event = {
						id = reich_shared.25
						days = 2
					}
				}
			}
			JAP = {
				country_event = {
					id = jap.204
					days = 2
				}
			}
			USA = {
				country_event = {
					id = USA.1916
					days = 2
				}
			}
		}
	}
	option = {#Play as Falange
		name = iberiawars.9.b
		trigger = { is_ai = no }
		SPS = {
			hidden_effect = {
				load_oob = Iberian_Wars_SPS
				if = {
					limit = {
						has_dlc = "Man the Guns"
					}
					load_oob = Iberian_Wars_SPS_naval_mtg
				}
				else = {
					load_oob = Iberian_Wars_SPS_naval
				}
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_SPS
						}
					}
					apply_war_buff_with_10_divisions = yes
				}
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
			declare_war_on = {
				target = SPR
				type = annex_everything
			}
		}
		SPS = {
			change_tag_from = IBR
		}

		hidden_effect = {
			country_event = {
				id = iberiawars.3000
				days = 2
			}
		}
	}
}

country_event = {#Fernando Seizes The Straits
	id = iberiawars.10
	title = iberiawars.10.t
	desc = iberiawars.10.d
	picture = GFX_report_event_generic_dam_1
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.10"
		hidden_effect = {
			GIB = {
				transfer_state = 118
				transfer_state = 290
				transfer_state = 1545
				transfer_state = 1547
				add_state_core = 118
				add_state_core = 290
				add_state_core = 1545
				add_state_core = 1547
			}
		}
	}
	option = {
		name = iberiawars.10.a #AHHHHHHHHHHHHHHHHHHHHHHH

		hidden_effect = {
			GIB = {
				load_oob = Iberian_Wars_GIB
			}
		}
	}
	option = {
		name = iberiawars.10.b #Hell Yeah!
		trigger = { is_ai = no }
		GIB = {
			change_tag_from = IBR
		}
		hidden_effect = {
			GIB = {
				load_oob = Iberian_Wars_GIB
			}
		}
	}
}
############################################################Super event triggering
country_event = {#showing super event to falang
	id = iberiawars.3000
	title = iberiawars.3000.t
	desc = iberiawars.3000.d
	picture = GFX_report_event_IBR_road_work_2
	is_triggered_only = yes
	fire_only_once = yes
	hidden = yes
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.3000"
	}
	immediate = {
		every_country = {
			limit = { is_ai = no }
			set_temp_variable = { TNO_temp_super_event = token:SE_IBERIAN_WARS }
			TNO_fire_super_event = yes
		}
	}
	option = {
		name = iberiawars.3000.a
	}
}
########################################################War exhaustions
country_event = {#TBA Rises 1
	id = iberiawars.11
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.11" }
	title = iberiawars.11.t
	desc = iberiawars.11.d
	picture = GFX_report_event_generic_rebels
	hidden = yes
	fire_only_once = yes
	is_triggered_only = yes #moved trigger elsewhere
	option = {
		if = {
			limit = {
				SPS = {
					exists = yes
				}
			}
			SPS = {
				country_event = {
					id = iberiawars.12
					days = 1
				}
			}
		}
	}
}

country_event = {#TBA Spawns
	id = iberiawars.12
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.12" }
	title = iberiawars.12.t
	desc = iberiawars.12.d
	picture = GFX_report_event_IBR_cnt_barricades
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			TBA = {
				add_ideas = Iberian_Wars_Minor
			}
		}
	}
	option = {
		name = iberiawars.12.a #Play SPS
		TBA = {
			transfer_state = 983
			add_state_core = 983
			hidden_effect = {
				load_oob = Iberian_Wars_TBA
			}
		}
		SPS = {
			declare_war_on = {
				target = TBA
				type = annex_everything
			}
		}
	}
	option = {
		name = iberiawars.12.b #Play TBA
		trigger = { is_ai = no }
		TBA = {
			transfer_state = 983
			add_state_core = 983
			hidden_effect = {
				load_oob = Iberian_Wars_TBA
			}
			change_tag_from = SPS
		}
		SPS = {
			declare_war_on = {
				target = TBA
				type = annex_everything
			}
		}
	}
}
country_event = {#National Redemption Front spawn
	id = iberiawars.13
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.13"
		set_global_flag = FSR_has_spawned
	}
	title = iberiawars.13.t
	desc = iberiawars.13.d
	picture = GFX_report_event_IBR_nrf_hoods
	is_triggered_only = yes
	fire_only_once = yes
	option = {
		name = iberiawars.13.a #Coup Fails - Civil War
		FSR = {
			if = {
				limit = {
					174 = {
						is_controlled_by = SPS
					}
				}
				transfer_state = 174
				add_state_core = 174
			}
			if = {
				limit = {
					994 = {
						is_controlled_by = SPS
					}
				}
				transfer_state = 994
				add_state_core = 994
			}
			transfer_state = 995
			add_state_core = 995
			hidden_effect = {
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_FSR
						}
					}
					apply_war_buff_with_10_divisions = yes
				}
			}
			IBRWarsAddIBRclaims = yes
			FSR = {
				declare_war_on = {
					target = SPS
					type = annex_everything
				}
				declare_war_on = {
					target = SPR
					type = annex_everything
				}
				declare_war_on = {
					target = IBR
					type = annex_everything
				}
				declare_war_on = {
					target = GAL
					type = annex_everything
				}
				declare_war_on = {
					target = BSQ
					type = annex_everything
				}
				declare_war_on = {
					target = TBA
					type = annex_everything
				}
				declare_war_on = {
					target = CTL
					type = annex_everything
				}
				declare_war_on = {
					target = CNT
					type = annex_everything
				}
			}
			FSR = {
				add_ideas = Iberian_Wars_Major
				load_oob = Iberian_Wars_FSR
			}
		}

	}
	option = {
		name = iberiawars.13.b #Coup Fails - Play FSR Anyway
		trigger = { is_ai = no }
		FSR = {
			if = {
				limit = {
					174 = {
						is_controlled_by = SPS
					}
				}
				transfer_state = 174
				add_state_core = 174
			}
			if = {
				limit = {
					994 = {
						is_controlled_by = SPS
					}
				}
				transfer_state = 994
				add_state_core = 994
			}
			transfer_state = 995
			add_state_core = 995
			hidden_effect = {
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_FSR
						}
					}
					apply_war_buff_with_10_divisions = yes
				}
			}
			change_tag_from = SPS
		}
		FSR = {
			IBRWarsAddIBRclaims = yes
			declare_war_on = {
				target = SPS
				type = annex_everything
			}
			declare_war_on = {
				target = SPR
				type = annex_everything
			}
			declare_war_on = {
				target = IBR
				type = annex_everything
			}
			declare_war_on = {
				target = GAL
				type = annex_everything
			}
			declare_war_on = {
				target = BSQ
				type = annex_everything
			}
			declare_war_on = {
				target = TBA
				type = annex_everything
			}
			declare_war_on = {
				target = CTL
				type = annex_everything
			}
			declare_war_on = {
				target = CNT
				type = annex_everything
			}
			FSR = {
				add_ideas = Iberian_Wars_Major
				load_oob = Iberian_Wars_FSR
			}
		}
	}
}
country_event = {#Portuguese Republic Spawns in GNS
	id = iberiawars.15
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.15" }
	title = iberiawars.15.t
	desc = iberiawars.15.d
	picture = GFX_report_event_IBR_portuguese_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		set_global_flag = DemPortugalSpawns
	}
	option = {
		name = iberiawars.15.a #Play GNS
		RPP = {
			transfer_state = 179
			transfer_state = 1000
			transfer_state = 1004
			add_state_core = 179
			add_state_core = 1000
			add_state_core = 1004
		}
		hidden_effect = {
			RPP = {
				load_oob = Iberian_Wars_RPP
			}
			RPP = {
				add_ideas = Iberian_Wars_Major
				IBRWarsAddPORclaims = yes
			}
			if = {
				limit = {
					OR = {
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_RPP
						}
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_PPR
						}
					}
				}
				RPP = {
					apply_war_buff_with_5_divisions = yes
				}
			}
		}
		RPP = {
			declare_war_on = {
				target = POR
				type = civil_war
			}
			declare_war_on = {
				target = GNS
				type = civil_war
			}
		}
	}
	option = {
		name = iberiawars.15.b #Play DemPortugal
		trigger = { is_ai = no }

		RPP = {
			transfer_state = 179
			transfer_state = 1000
			transfer_state = 1004
			add_state_core = 179
			add_state_core = 1000
			add_state_core = 1004
		}
		RPP = {
			change_tag_from = GNS
		}
		hidden_effect = {
			RPP = {
				load_oob = Iberian_Wars_RPP
			}
			RPP = {
				add_ideas = Iberian_Wars_Major
				IBRWarsAddPORclaims = yes
			}
			if = {
				limit = {
					OR = {
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_RPP
						}
						has_game_rule = {
							rule = POR_IBERIAN_WARS_OTCOME
							option = POR_IBERIAN_WARS_OTCOME_PPR
						}
					}
				}
				RPP = {
					apply_war_buff_with_5_divisions = yes
				}
			}
		}
		RPP = {
			declare_war_on = {
				target = GNS
				type = civil_war
			}
			declare_war_on = {
				target = POR
				type = civil_war
			}
		}
	}
}
country_event = {#Portuguese People's Republic Spawns in RPP
	id = iberiawars.16
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.16" }
	title = iberiawars.16.t
	desc = iberiawars.16.d
	picture = GFX_report_event_generic_commune_protest
	trigger = {
		AND = {
			tag = RPP
			RPP = {
				check_variable = { IberianWarExhaustion > 40 }
			}
			NOT = {
				has_global_flag = ComPortugalSpawns
			}
			179 = {
				is_controlled_by = RPP
			}
			1004 = {
				is_controlled_by = RPP
			}
		}
	}
	fire_only_once = yes
	immediate = {
		set_global_flag = ComPortugalSpawns
	}
	option = {#Play as Portuguese Republic
		name = iberiawars.16.a
		PPR = {
			transfer_state = 179
			transfer_state = 1004
			add_state_core = 179
			add_state_core = 1004
		}
		hidden_effect = {
			PPR = {
				load_oob = Iberian_Wars_PPR
			}
			PPR = {
				add_ideas = Iberian_Wars_Major
				IBRWarsAddPORclaims = yes
			}
			if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_PPR
					}
				}
				RPP = {
					remove_war_buff = yes
				}
				PPR = {
					set_country_flag = request_strong_CCP_buff
					apply_war_buff_with_5_divisions = yes
				}
			}
			else_if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_RPP
					}
					RPP = {
						NOT = {
							has_idea = Custom_TNO_war_buff
						}
					}
				}
				RPP = {
					apply_war_buff_with_5_divisions = yes
				}
			}
			else_if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_POR
					}
					POR = {
						NOT = {
							has_idea = Custom_TNO_war_buff
						}
					}
				}
				POR = {
					apply_war_buff_with_5_divisions = yes
				}
			}
			else_if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_GNS
					}
					GNS = {
						NOT = {
							has_idea = Custom_TNO_war_buff
						}
					}
				}
				GNS = {
					apply_war_buff_with_5_divisions = yes
				}
			}
		}
		PPR = {
			declare_war_on = {
				target = RPP
				type = civil_war
			}
			declare_war_on = {
				target = GNS
				type = civil_war
			}
			declare_war_on = {
				target = POR
				type = civil_war
			}
		}
	}
	option = {#Play as Portuguese People's Republic
		name = iberiawars.16.b
		trigger = { is_ai = no }
		PPR = {
			transfer_state = 179
			transfer_state = 1004
			add_state_core = 179
			add_state_core = 1004
		}
		PPR = {
			change_tag_from = RPP
		}
		hidden_effect = {
			PPR = {
				load_oob = Iberian_Wars_PPR
			}
			PPR = {
				add_ideas = Iberian_Wars_Major
				IBRWarsAddPORclaims = yes
			}
			if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_PPR
					}
				}
				RPP = {
					remove_war_buff = yes
				}
				PPR = {
					set_country_flag = request_strong_CCP_buff
					apply_war_buff_with_5_divisions = yes
				}
			}
			else_if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_RPP
					}
					RPP = {
						NOT = {
							has_idea = Custom_TNO_war_buff
						}
					}
				}
				RPP = {
					apply_war_buff_with_5_divisions = yes
				}
			}
			else_if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_POR
					}
					POR = {
						NOT = {
							has_idea = Custom_TNO_war_buff
						}
					}
				}
				POR = {
					apply_war_buff_with_5_divisions = yes
				}
			}
			else_if = {
				limit = {
					has_game_rule = {
						rule = POR_IBERIAN_WARS_OTCOME
						option = POR_IBERIAN_WARS_OTCOME_GNS
					}
					GNS = {
						NOT = {
							has_idea = Custom_TNO_war_buff
						}
					}
				}
				GNS = {
					apply_war_buff_with_5_divisions = yes
				}
			}
		}
		PPR = {
			declare_war_on = {
				target = RPP
				type = civil_war
			}
			declare_war_on = {
				target = GNS
				type = civil_war
			}
			declare_war_on = {
				target = POR
				type = civil_war
			}
		}
	}
}
country_event = {#ANDALUSIA
	id = iberiawars.17
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.17" }
	title = iberiawars.17.t
	desc = iberiawars.17.d
	picture = GFX_report_event_IBR_iberian_wars_7
	is_triggered_only = yes
	fire_only_once = yes
	option = {
		name = iberiawars.17.a
		ADL = {
			add_state_core = 169
			add_state_core = 988
			add_state_core = 173
			add_state_core = 1003
			transfer_state = 169
			transfer_state = 988
			transfer_state = 173
			transfer_state = 1003
		}
		hidden_effect = {
			ADL = {
				inherit_technology = SPR
				load_oob = Iberian_Wars_SPR_5
			}
			ADL = {
				add_ideas = Iberian_Wars_Minor
			}
		}
	}
	option = {
		name = iberiawars.17.b
		trigger = { is_ai = no }
		ADL = {
			add_state_core = 169
			add_state_core = 988
			add_state_core = 173
			add_state_core = 1003
			transfer_state = 169
			transfer_state = 988
			transfer_state = 173
			transfer_state = 1003
		}
		ADL = {
			change_tag_from = SPR
		}
		hidden_effect = {
			ADL = {
				inherit_technology = SPR
				load_oob = Iberian_Wars_SPR_5
			}
			ADL = {
				add_ideas = Iberian_Wars_Minor
			}
		}
	}
}

country_event = {#FRENTE AZUL
	id = iberiawars.18
	immediate = {
		log = "[GetDateText]: [Root.GetName]: event iberiawars.18"
		set_global_flag = FZL_has_spawned
		hidden_effect = {
			FZL = {
				IBRWarsAddSPSclaims = yes
			}
			every_unit_leader = {
				limit = { has_id = 1332 }
				set_nationality = FZL
			}
		}
	}
	title = iberiawars.18.t
	desc = iberiawars.18.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = no
	fire_only_once = yes
	trigger = {
		AND = {
			tag = SPS
			SPS = {
				check_variable = { IberianWarExhaustion > 70 }
			}
			FSR = {
				exists = yes
			}
		}
	}

	option = {
		name = iberiawars.18.a
		hidden_effect = {
			SPS = {
				random_owned_state = {
					FZL = {
						transfer_state = PREV
					}
				}
			}
			every_country = {
				limit = {
					has_offensive_war_with = SPS
				}
				declare_war_on = {
					target = FZL
					type = annex_everything
				}
			}
			every_country = {
				limit = {
					has_defensive_war_with = SPS
				}
				FZL = {
					declare_war_on = {
						target = PREV
						type = annex_everything
					}
				}
			}
			GER = {
				set_temp_variable = { target = SPS }
				TNO_clear_and_recall_volunteers = yes
			}
		}
		FZL = {
			change_tag_from = SPS
		}
		FZL = {
			annex_country = {
				target = SPS
				transfer_troops = yes
			}
			declare_war_on = {
				target = FSR
				type = annex_everything
			}
		}
		hidden_effect = {
			FZL = {
				add_ideas = Iberian_Wars_Major
				if = {
					limit = {
						has_game_rule = {
							rule = SPA_IBERIAN_WARS_OTCOME
							option = SPA_IBERIAN_WARS_OTCOME_FZL
						}
					}
					set_country_flag = request_strong_CCP_buff
					apply_war_buff_with_20_divisions = yes
				}
			}
		}
		FZL = {
			every_controlled_state = {
				add_core_of = FZL
			}
		}
	}
}
country_event = {#ETA
	id = iberiawars.19
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.19" }
	title = iberiawars.19.t
	desc = iberiawars.19.d
	picture = GFX_report_event_IBR_eta_protest
	fire_only_once = yes
	trigger = {
		AND = {
			tag = BSQ
			BSQ = {
				check_variable = { IberianWarExhaustion > 50 }
			}
		}
	}
	option = {
		name = iberiawars.19.a
		add_ideas = BSQ_Jose_Miguel_Benaran_hog
		add_ideas = BSQ_Angel_Otaegui_for
		add_ideas = BSQ_Domingo_Iturbide_eco
		add_ideas = BSQ_Xabier_Zumalde_sec
		set_politics = {
			ruling_party = communist
		}

		add_corps_commander_role = {
			character = BSQ_Txabi_Etxebarrieta
			traits = {}
			skill = 3
			attack_skill = 3
			defense_skill = 2
			planning_skill = 4
			logistics_skill = 3
			legacy_id = 1430
		}

		add_corps_commander_role = {
			character = BSQ_Federico_Krutwig
			traits = {}
			skill = 3
			attack_skill = 3
			defense_skill = 2
			planning_skill = 4
			logistics_skill = 3
			legacy_id = 1432
		}

		add_field_marshal_role = {
			character = BSQ_Jose_Quesada
			traits = {}
			skill = 3
			attack_skill = 3
			defense_skill = 2
			planning_skill = 4
			logistics_skill = 3
			legacy_id = 1433
		}
		remove_unit_leader_role = BSQ_Antonio_Ibanez
		remove_unit_leader_role = BSQ_Carlos_Villar
		remove_unit_leader_role = BSQ_Joseba_Elosegui
		remove_unit_leader_role = BSQ_Pablo_Beldarrain
		remove_unit_leader_role = BSQ_Juan_Castro
		remove_unit_leader_role = BSQ_Alejo_Bilbao

	}
}
country_event = {#CNT
	id = iberiawars.32
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.32" }
	title = iberiawars.32.t
	desc = iberiawars.32.d
	picture = GFX_report_event_IBR_cnt_anarchists
	fire_only_once = yes
	trigger = {
		AND = {
			tag = CTL
			CTL = {
				check_variable = { IberianWarExhaustion > 50 }
			}
		}
	}
	option = {
		name = iberiawars.32.a
		CNT = {
			transfer_state = 986
			add_state_core = 986
			IBRWarsAddCNTclaims = yes
			declare_war_on = {
				target = CTL
				type = annex_everything
			}
		}
		hidden_effect = {
			CNT = {
				load_oob = Iberian_Wars_CNT
			}
			CNT = {
				add_ideas = Iberian_Wars_Minor
			}
		}
	}
	option = {
		name = iberiawars.32.b
		trigger = { is_ai = no }
		CNT = {
			transfer_state = 986
			add_state_core = 986
			IBRWarsAddCNTclaims = yes
			declare_war_on = {
				target = CTL
				type = annex_everything
			}
		}
		CNT = {
			change_tag_from = CTL
		}
		hidden_effect = {
			CNT = {
				load_oob = Iberian_Wars_CNT
			}
			CNT = {
				add_ideas = Iberian_Wars_Minor
			}
		}
	}
}
country_event = {#Proclamation of the Kingdom of Spain
	id = iberiawars.30
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.30" }
	title = iberiawars.30.t
	desc = iberiawars.30.d
	picture = GFX_report_event_IBR_iberian_wars_1
	trigger = {
		tag = SPR
		SPR = {
			check_variable = { IberianWarExhaustion > 35 }
		}
	}
	fire_only_once = yes
	option = {
		name = iberiawars.30.a
		add_ideas = SPR_juan_III_idea
		add_ideas = SPR_Fernando_Miranda_hog
		set_cosmetic_tag = SPR_kingdom
	}
}
country_event = {#Military takeover the Kingdom of Spain
	id = iberiawars.31
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.31" }
	title = iberiawars.31.t
	desc = iberiawars.31.d
	picture = GFX_report_event_IBR_iberian_wars_10
	trigger = {
		tag = SPR
		SPR = {
			check_variable = { IberianWarExhaustion > 70 }
		}
	}
	fire_only_once = yes
	option = {
		name = iberiawars.31.a
		add_ideas = SPR_Nicolas_Cotoner_hog
		add_ideas = SPR_Antonio_Garrigues_for
		set_cosmetic_tag = SPR_military
		set_politics = {
			ruling_party = paternalism
		}
		add_popularity = {
			ideology = paternalism
			popularity = 0.30
		}
		add_field_marshal_role = {
			character = SPR_Sabino_Fernandez
			traits = { }
			skill = 4
			attack_skill = 3
			defense_skill = 4
			planning_skill = 3
			logistics_skill = 3
			legacy_id = 1416
		}
		hidden_effect = {
			country_event = {
				id = iberiawars.17
				days = 5
			}
		}
	}
}
#############################################################War Exhaustion Events
country_event = {
	id = ibrwarexhaustion.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarexhaustion.1" }
	title = ibrwarexhaustion.1.t
	desc = ibrwarexhaustion.1.d
	picture = GFX_report_event_lithuania_army
	hidden = yes
	is_triggered_only = yes

	option = {
		name = ibrwarexhaustion.1.a
		add_political_power = -5
		set_country_flag = WarExEv1Fired
		IBRProcessExhaustionSpirit = yes
	}
}

country_event = {
	id = ibrwarexhaustion.2
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarexhaustion.2" }
	title = ibrwarexhaustion.2.t
	desc = ibrwarexhaustion.2.d
	picture = GFX_report_event_lithuania_army
	hidden = yes
	is_triggered_only = yes

	option = {
		name = ibrwarexhaustion.2.a
		add_political_power = -10
		set_country_flag = WarExEv2Fired
		IBRProcessExhaustionSpirit = yes
	}
}

country_event = {
	id = ibrwarexhaustion.3
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarexhaustion.3" }
	title = ibrwarexhaustion.3.t
	desc = ibrwarexhaustion.3.d
	picture = GFX_report_event_lithuania_army
	hidden = yes
	is_triggered_only = yes

	option = {
		name = ibrwarexhaustion.3.a
		add_political_power = -25
		set_country_flag = WarExEv3Fired
		IBRProcessExhaustionSpirit = yes
	}
}

country_event = {
	id = ibrwarexhaustion.4
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarexhaustion.4" }
	title = ibrwarexhaustion.4.t
	desc = ibrwarexhaustion.4.d
	picture = GFX_report_event_lithuania_army
	hidden = yes
	is_triggered_only = yes

	option = {
		name = ibrwarexhaustion.4.a
		add_political_power = -50
		set_country_flag = WarExEv4Fired
		IBRProcessExhaustionSpirit = yes
	}
}

country_event = {
	id = ibrwarexhaustion.5
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarexhaustion.5" }
	title = ibrwarexhaustion.5.t
	desc = ibrwarexhaustion.5.d
	picture = GFX_report_event_lithuania_army
	hidden = yes
	is_triggered_only = yes

	option = {
		name = ibrwarexhaustion.5.a
		add_political_power = -100
		set_country_flag = WarExEv5Fired
		IBRProcessExhaustionSpirit = yes
	}
}
#############################################################War Stages Events
country_event = {#Set Stage Two
	id = ibrwarstages.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarstages.1" }
	title = ibrwarstages.1.t
	desc = ibrwarstages.1.d
	picture = GFX_report_event_IBR_road_work_2
	is_triggered_only = yes
	fire_only_once = yes
	hidden = yes
	option = {
		name = ibrwarstages.1.a
		ZZZ = {
			swap_ideas = {
				remove_idea = IBR_iberiawars_stage_one
				add_idea = IBR_iberiawars_stage_two
			}
			country_event = {
				id = ibrwarstages.2
				days = 180
			}
		}
	}
}

country_event = {#Set Stage Three
	id = ibrwarstages.2
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarstages.2" }
	title = ibrwarstages.2.t
	desc = ibrwarstages.2.d
	picture = GFX_report_event_IBR_road_work_2
	is_triggered_only = yes
	fire_only_once = yes
	hidden = yes
	option = {
		name = ibrwarstages.2.a
		ZZZ = {
			swap_ideas = {
				remove_idea = IBR_iberiawars_stage_two
				add_idea = IBR_iberiawars_stage_three
			}
			country_event = {
				id = ibrwarstages.3
				days = 180
			}
		}
	}
}

country_event = {#Set Stage Four
	id = ibrwarstages.3
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarstages.3" }
	title = ibrwarstages.3.t
	desc = ibrwarstages.3.d
	picture = GFX_report_event_IBR_road_work_2
	is_triggered_only = yes
	fire_only_once = yes
	hidden = yes
	option = {
		name = ibrwarstages.3.a
		ZZZ = {
			swap_ideas = {
				remove_idea = IBR_iberiawars_stage_three
				add_idea = IBR_iberiawars_stage_four
			}
			country_event = {
				id = ibrwarstages.4
				days = 180
			}
		}
	}
}

country_event = {#Set Stage Five
	id = ibrwarstages.4
	immediate = { log = "[GetDateText]: [Root.GetName]: event ibrwarstages.4" }
	title = ibrwarstages.4.t
	desc = ibrwarstages.4.d
	picture = GFX_report_event_IBR_road_work_2
	is_triggered_only = yes
	fire_only_once = yes
	hidden = yes
	option = {
		name = ibrwarstages.4.a
		ZZZ = {
			swap_ideas = {
				remove_idea = IBR_iberiawars_stage_four
				add_idea = IBR_iberiawars_stage_five
			}
		}
	}
}
#############################################################################Peace events
country_event = {#Peace in Portugal - Salazarist
	id = iberiawars.20
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.20" }
	title = iberiawars.20.t
	desc = iberiawars.20.d
	picture = GFX_report_event_IBR_portugal_unity
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			POR = {
				IBRWarsResign = yes
			}
		}
	}
	option = {
		name = iberiawars.20.a
		every_country = {
			news_event = {
				id = WORLD.492
			}
		}
		IBRWarsCheckPeace = yes
		TNO_Country_Closing_Screen_Show = yes
	}
}
country_event = {#Peace in Portugal - Democrats
	id = iberiawars.21
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.21" }
	title = iberiawars.21.t
	desc = iberiawars.21.d
	picture = GFX_report_event_IBR_portuguese_protest
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			RPP = {
				IBRWarsResign = yes
			}
		}
	}
	option = {
		name = iberiawars.21.a
		every_country = {
			news_event = {
				id = WORLD.493
			}
		}
		IBRWarsCheckPeace = yes
		TNO_Country_Closing_Screen_Show = yes
	}
}
country_event = {#Peace in Portugal - Communists
	id = iberiawars.22
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.22" }
	title = iberiawars.22.t
	desc = iberiawars.22.d
	picture = GFX_report_event_IND_communists
	is_triggered_only = yes

	fire_only_once = yes
	immediate = {
		hidden_effect = {
			PPR = {
				IBRWarsResign = yes
			}
		}
	}
	option = {
		name = iberiawars.22.a
		every_country = {
			news_event = {
				id = WORLD.494
			}
		}
		IBRWarsCheckPeace = yes
		TNO_Country_Closing_Screen_Show = yes
		set_cosmetic_tag = PPR_unified
	}
}

country_event = {#Peace in Iberia - GNS
	id = iberiawars.23
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.23" }
	title = iberiawars.23.t
	desc = iberiawars.23.d
	picture = GFX_report_event_IBR_iberian_wars_gns_kaulza_speech
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			GNS = {
				GNS_Joao_Bruno = { set_nationality = TBA }
				GNS_Francisco_Roxo = { set_nationality = CTL }
				GNS_Silvino_Marques = { set_nationality = SPS }
				IBRWarsResign = yes
				transfer_state = 982
				transfer_state = 171
				transfer_state = 178
				every_controlled_state = {
					add_core_of = PREV
				}
			}
			TBA = {
				transfer_state = 983
				transfer_state = 174
				transfer_state = 172
				transfer_state = 993
				transfer_state = 984
				transfer_state = 985
				transfer_state = 994
				transfer_state = 995
				transfer_state = 176
				transfer_state = 166
				every_controlled_state = {
					add_core_of = PREV
				}
				add_country_leader_role = {
					character = GNS_Joao_Bruno
					promote_leader = yes
					country_leader = {
						expire = "1999.1.1"
						ideology = ultranationalism_stratocratic_corporatism_subtype
						traits = { }
						id = -1
					}
				}
				set_cosmetic_tag = TBA_GNS_district
				IBRWarsResign = yes
			}
			set_autonomy = {
				target = TBA
				autonomy_state = autonomy_military_government
			}
			CTL = {
				transfer_state = 165
				transfer_state = 986
				transfer_state = 1012
				transfer_state = 987
				transfer_state = 167
				transfer_state = 168
				if = {
					limit = {
						177 = {
							NOT = { is_controlled_by = ITA }
						}
					}
					transfer_state = 177
				}
				every_controlled_state = {
					add_core_of = PREV
				}
				add_country_leader_role = {
					character = GNS_Francisco_Roxo
					promote_leader = yes
					country_leader = {
						expire = "1999.1.1"
						ideology = ultranationalism_stratocratic_corporatism_subtype
						traits = { }
						id = -1
					}
				}
				if = {
					limit = {
						NOT = {
							ITA = {
								controls_state = 177
							}
						}
					}
					transfer_state = 177
				}
				IBRWarsResign = yes
				set_cosmetic_tag = CTL_GNS_district
			}
			set_autonomy = {
				target = CTL
				autonomy_state = autonomy_military_government
			}
			SPS = {
				transfer_state = 1003
				transfer_state = 173
				transfer_state = 169
				transfer_state = 988
				transfer_state = 1001
				transfer_state = 1002
				transfer_state = 175
				transfer_state = 170
				transfer_state = 41
				transfer_state = 1013
				transfer_state = 999
				transfer_state = 996
				transfer_state = 1701
				transfer_state = 1702
				every_controlled_state = {
					add_core_of = PREV
				}
				add_country_leader_role = {
					character = GNS_Silvino_Marques
					promote_leader = yes
					country_leader = {
						expire = "1999.1.1"
						ideology = ultranationalism_stratocratic_corporatism_subtype
						traits = { }
						id = -1
					}
				}
				set_cosmetic_tag = SPS_GNS_district
				IBRWarsResign = yes
			}
			set_autonomy = {
				target = SPS
				autonomy_state = autonomy_military_government
			}
		}
	}
	option = {
		name = iberiawars.23.a
		every_country = {
			news_event = {
				id = WORLD.495
			}
		}
		TNO_Country_Closing_Screen_Show = yes
	}
}
country_event = {#Peace in Iberia - IBR
	id = iberiawars.24
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.24" }
	title = iberiawars.24.t
	desc = iberiawars.24.d
	picture = GFX_report_event_IBR_invitation
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			IBR = {
				IBRWarsResign = yes
			}
		}
	}
	option = {
		name = iberiawars.24.a
		every_country = {
			news_event = {
				id = WORLD.496
			}
		}
		TNO_Country_Closing_Screen_Show = yes
	}
}
country_event = {#Peace in Iberia - NRF
	id = iberiawars.25
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.25" }
	title = iberiawars.25.t
	desc = iberiawars.25.d
	picture = GFX_report_event_IBR_nrf_hoods
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			FSR = {
				IBRWarsResign = yes
			}
		}
	}
	option = {
		name = iberiawars.25.a
		every_country = {
			news_event = {
				id = WORLD.499
			}
		}
		TNO_Country_Closing_Screen_Show = yes
	}
}
country_event = {#Peace in Spain - Falangists
	id = iberiawars.26
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.26" }
	title = iberiawars.26.t
	desc = iberiawars.26.d
	picture = GFX_report_event_IBR_falange_standard_bearers
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			SPS = {
				IBRWarsResign = yes
			}
		}
	}
	option = {
		name = iberiawars.26.a
		every_country = {
			news_event = {
				id = WORLD.497
			}
		}
		IBRWarsCheckPeace = yes
		TNO_Country_Closing_Screen_Show = yes
		set_cosmetic_tag = SPS_unified
	}
}
country_event = {#Peace in Spain - Frente Azul
	id = iberiawars.27
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.27" }
	title = iberiawars.27.t
	desc = iberiawars.27.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = yes
	fire_only_once = yes
	option = {#On to Portugal
		name = iberiawars.27.a
		set_cosmetic_tag = FZL_unified
		set_country_flag = FZL_war_portugal
		declare_war_on = {
			target = POR
			type = annex_everything
		}
		declare_war_on = {
			target = GNS
			type = annex_everything
		}
		declare_war_on = {
			target = RPP
			type = annex_everything
		}
		declare_war_on = {
			target = PPR
			type = annex_everything
		}
	}
}
country_event = {#Conquered Portugal - Frente Azul
	id = iberiawars.29
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.29" }
	title = iberiawars.29.t
	desc = iberiawars.29.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			GNS = {
				set_temp_variable = { TNO_economy_type_temp = token:Econ_Type_Planned }
				econ_type_change = yes
				econ_join_sphere_GER = yes
				add_ideas = Pakt_Observer
				retire_character = GNS_Kaulza_Arriaga
				annex_country = {
					target = POR
					transfer_troops = no
				}
				annex_country = {
					target = PPR
					transfer_troops = no
				}
				annex_country = {
					target = RPP
					transfer_troops = no
				}
				every_state = {
					limit = {
						is_portuguese_state = yes
					}
					add_core_of = GNS
				}
				IBRWarsResign = yes
			}
			GNS = {
				save_party_popularities = yes
			}
			FZL = {
				remove_ideas = {
					Iberian_Wars_Major
				}
				set_autonomy = {
					target = GNS
					autonomy_state = autonomy_occupied_territory
				}
			}
			GNS = {
				apply_party_popularities = yes
			}
		}
	}
	option = {#Victory!
		name = iberiawars.29.a
		every_country = {
			news_event = {
				id = WORLD.500
			}
		}
		GER = { country_event = { id = reich_shared.24 days = 7 } }
		TNO_Country_Closing_Screen_Show = yes
	}
}
country_event = {#Peace in Spain - Democrats
	id = iberiawars.28
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.28" }
	title = iberiawars.28.t
	desc = iberiawars.28.d
	picture = GFX_report_event_IBR_spanish_republic_protest
	hidden = yes
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			IBRWarsResign = yes
		}
	}
	option = {
		name = iberiawars.28.a
		every_country = {
			news_event = {
				id = WORLD.498
			}
		}
		IBRWarsCheckPeace = yes
		TNO_Country_Closing_Screen_Show = yes
		hidden_effect = {
			SPR = {
				add_ideas = OFN_Observer
				meta_effect = { #sets up next election date in country ui
					text = {
						set_politics = {
							ruling_party = liberalism
							last_election = "[current_election_date]"
							elections_allowed = yes
							election_frequency = 48
						}
					}
					current_election_date = "[?global.date.GetDateStringNoHour]"
				}
			}
		}
	}
}

country_event = {#Peace in Portugal - GNS
	id = iberiawars.33
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.33" }
	title = iberiawars.33.t
	desc = iberiawars.33.d
	picture = GFX_report_event_IBR_iberian_wars_gns_3
	is_triggered_only = yes
	option = {
		name = iberiawars.33.a
		set_country_flag = GNS_war_Spain
		every_country = {
			limit = {
				is_iberianwar_mainland_nation = yes
				NOT = {
					tag = GNS
					is_puppet_of = GNS
				}
			}
			GNS = {
				declare_war_on = {
					target = PREV
					type = annex_everything
				}
			}
		}
	}
}

country_event = {#Conquered Portugal - Spanish Republic
	id = iberiawars.34
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.34" }
	title = iberiawars.34.t
	desc = iberiawars.34.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			SPR = {
				set_autonomy = {
					target = GNS
					autonomy_state = autonomy_occupied_territory
				}
			}
			GNS = {
				IBRWarsResign = yes
				clr_country_flag = GNS_war_Spain
				set_temp_variable = { TNO_economy_type_temp = token:Econ_Type_Capitalism }
				econ_type_change = yes
				econ_join_sphere_USA = yes
				add_ideas = OFN_Observer
				set_cosmetic_tag = POR_puppet
				set_politics = {
					ruling_party = paternalism
					elections_allowed = no
				}
				set_popularities = {
					paternalism = 75
					ultranationalism = 25
				}
				fill_empty_minister_nochecks = yes
			}
		}
	}
	option = {#Victory!
		name = iberiawars.34.a
	}
}

country_event = {#Conquered Portugal - Spanish State
	id = iberiawars.35
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.35" }
	title = iberiawars.35.t
	desc = iberiawars.35.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			SPS = {
				set_autonomy = {
					target = GNS
					autonomy_state = autonomy_occupied_territory
				}
			}
			GNS = {
				IBRWarsResign = yes
				clr_country_flag = GNS_war_Spain
				set_temp_variable = { TNO_economy_type_temp = token:Econ_Type_Capitalism }
				econ_type_change = yes
				econ_join_sphere_GER = yes
				add_ideas = Pakt_Observer
				every_state = {
					limit = {
						is_portuguese_state = yes
					}
					add_core_of = GNS
				}
				set_cosmetic_tag = POR_puppet
				set_politics = {
					ruling_party = fascism
					elections_allowed = no
				}
				set_popularities = {
					paternalism = 5
					ultranationalism = 20
					fascism = 75
				}
				fill_empty_minister_nochecks = yes
			}
		}
	}
	option = {#Victory!
		name = iberiawars.35.a
	}
}

country_event = {#Conquered Spain - Portuguese Republic/Portuguese Provisional Republic Victory
	id = iberiawars.36
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.36" }
	title = iberiawars.36.t
	desc = iberiawars.36.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			SPR = {
				IBRWarsResign = yes
				set_temp_variable = { TNO_economy_subtype_temp = token:Econ_Subtype_Social_Market }
				econ_subtype_change = yes
				every_state = {
					limit = {
						is_spanish_state = yes
					}
					add_core_of = SPR
				}
				set_cosmetic_tag = SPR_puppet
				set_politics = {
					ruling_party = paternalism
					elections_allowed = yes
				}
				add_popularity = {
					ideology = paternalism
					popularity = 0.40
				}
				add_country_leader_role = {
					character = SPR_Provisional_Government
					promote_leader = yes
					country_leader = {
						expire = "1999.1.1"
						ideology = paternalism_provisional_government_subtype
						traits = { }
						id = -1
					}
				}
				set_party_name = {
					ideology = paternalism
					long_name = SPR_puppet_paternalism_party_long
					name = SPR_puppet_paternalism_party
				}
				econ_leave_sphere = yes
				fill_empty_minister_nochecks = yes
			}
		}
	}
	option = {#Victory!
		name = iberiawars.36.a
	}
}

country_event = {#Conquered Spain - Communist Portugal Victory
	id = iberiawars.37
	immediate = { log = "[GetDateText]: [Root.GetName]: event iberiawars.37" }
	title = iberiawars.37.t
	desc = iberiawars.37.d
	picture = GFX_report_event_IBR_frente_azul_flag
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		hidden_effect = {
			SPR = {
				save_party_popularities = yes
			}
			PPR = {
				set_autonomy = {
					target = SPR
					autonomy_state = autonomy_client_state
				}
			}
			SPR = {
				apply_party_popularities = yes
			}
			SPR = {
				IBRWarsResign = yes
				set_cosmetic_tag = SPR_puppet
				set_temp_variable = { TNO_economy_type_temp = token:Econ_Type_Planned }
				econ_type_change = yes
				add_popularity = {
					ideology = socialist
					popularity = 0.40
				}
				set_politics = {
					ruling_party = socialist
					elections_allowed = no
				}
				set_party_name = {
					ideology = socialist
					long_name = SPR_puppet_socialist_party_long
					name = SPR_puppet_socialist_party
				}
				add_country_leader_role = {
					character = SPR_Provisional_Government
					promote_leader = yes
					country_leader = {
						expire = "1999.1.1"
						ideology = socialist_revolutionary_frontism_subtype
						traits = { }
						id = -1
					}
				}
				econ_leave_sphere = yes
				fill_empty_minister_nochecks = yes
			}
		}
	}
	option = {#Victory!
		name = iberiawars.37.a
	}
}