﻿add_namespace = lar_spain 

# Election of 1936 - La Resistance Edition
country_event = {
	id = lar_spain.1
	title = spain.9.t
	desc = lar_spain.1.desc
	picture = GFX_report_event_election_vote
	
	is_triggered_only = yes

	fire_only_once = yes

	trigger = {
		tag = SPR
		has_dlc = "La Resistance"
	}

	immediate = {
		hidden_effect = {
			set_country_flag = SPR_spanish_elections_flag
			if = {
				limit = {
					focus_progress = {
						focus = SPR_the_popular_front
						progress > 0
					}
					NOT = { has_completed_focus = SPR_the_popular_front }
				}
				complete_national_focus = SPR_the_popular_front
				add_political_power = -35
			}
			if = {
				limit = {
					focus_progress = {
						focus = SPA_a_great_spain
						progress > 0
					}
					NOT = { has_completed_focus = SPA_a_great_spain }
				}
				complete_national_focus = SPA_a_great_spain
				add_political_power = -35
			}
			if = {
				limit = {
					has_completed_focus = SPR_the_popular_front
				}
				activate_mission = SPA_hand_over_the_ceda_campaign_chest_mission
				activate_mission = SPR_military_plot_republicans
				hidden_effect = {
					country_event = { id = lar_spain.4 } # Nationalists working against the government
					country_event = { id = lar_spain.5 }
					activate_mission = SPR_military_plot_republicans
					add_ideas = SPR_government_power_struggle
				}
			}
			if = {
				limit = {
					has_completed_focus = SPA_a_great_spain
				}
				random_list = {
					10 = {
						activate_mission = SPR_secure_the_guardia_de_asalto_mission
					}
					10 = {
						modifier = {
							factor = 0
							is_historical_focus_on = yes
						}
						activate_mission = SPR_secure_the_guardia_civil_mission
					}
				}
				activate_mission = SPA_military_plot_nationalists
				hidden_effect = {
					country_event = { id = lar_spain.3 } # Government working against the nationalists
					country_event = { id = lar_spain.5 days = 20 random_days = 10 }
					activate_mission = SPA_military_plot_nationalists
				}
			}
			every_state = {
				limit = {
					is_core_of = SPR
				}
				add_core_of = SPA
			}
		}
	}

	# Popular Front
	option = {
		name = lar_spain.1.a
		trigger = {
			NOT = {
				has_completed_focus = SPA_a_great_spain
			}
		}
		add_popularity = {
			ideology = communism
			popularity = 0.1
		}
		add_political_power = 5
		if = {
			limit = {
				NOT = {
					has_completed_focus = SPR_the_popular_front
				}
			}
			complete_national_focus = SPR_the_popular_front
			add_political_power = -35
			activate_mission = SPR_military_plot_republicans
			hidden_effect = {
				country_event = { id = lar_spain.4 days = 4 } # Nationalists working against the government
				country_event = { id = lar_spain.5 }
				activate_mission = SPR_military_plot_republicans
				if = {
					limit = {
						NOT = { has_active_mission = SPA_hand_over_the_ceda_campaign_chest_mission }
					}
					activate_mission = SPA_hand_over_the_ceda_campaign_chest_mission
				}
			}
		}
		effect_tooltip = { add_ideas = SPR_government_power_struggle }
		custom_effect_tooltip = SPR_republican_garrison_control_decisions_tt
	}

	# Falange
	option = {
		name = lar_spain.1.b
		trigger = {
			NOT = {
				has_completed_focus = SPR_the_popular_front
			}
		}
		add_popularity = {
			ideology = fascism
			popularity = 0.1
		}
		if = {
			limit = {
				NOT = {
					has_completed_focus = SPA_a_great_spain
				}
			}
			complete_national_focus = SPA_a_great_spain
			add_political_power = -35
			activate_mission = SPA_military_plot_nationalists
			hidden_effect = {
				country_event = { id = lar_spain.3 } # Government working against the nationalists
				country_event = { id = lar_spain.5 days = 20 random_days = 10 }
				activate_mission = SPA_military_plot_nationalists
				if = {
					limit = {
						NOT = {
							has_active_mission = SPR_secure_the_guardia_de_asalto_mission
							has_active_mission = SPR_secure_the_guardia_civil_mission
						}
					}
					random_list = {
						10 = {
							activate_mission = SPR_secure_the_guardia_de_asalto_mission
						}
						10 = {
							modifier = {
								factor = 0
								is_historical_focus_on = yes
							}
							activate_mission = SPR_secure_the_guardia_civil_mission
						}
					}
				}
			}
		}
		custom_effect_tooltip = SPA_nationalist_garrison_control_decisions_tt
	}
}

# Spanish Civil War - La Resistance Edition
country_event = {
	id = lar_spain.2
	title = lar_spain.2.t
	desc = lar_spain.2.desc
	picture = GFX_report_event_spain_civil_war_soldiers
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			every_owned_state = {
				limit = {
					is_core_of = ROOT
				}
				set_state_flag = SPR_core_of_spain_flag
			}
			set_global_flag = { flag = SPR_civil_war_startup value = 1 days = 3 } # Make AI avoid attacking for a few days
		}

#  #  ##  ### ###  ##  #  #  ##  #   ###  ## ###     ### ### ### ###  ##  ### 
## # #  #  #   #  #  # ## # #  # #    #  #    #      #   #   #   #   #  #  #  
# ## ####  #   #  #  # # ## #### #    #   #   #      ##  ##  ##  ##  #     #  
#  # #  #  #   #  #  # #  # #  # #    #    #  #      #   #   #   #   #  #  #  
#  # #  #  #  ###  ##  #  # #  # ### ### ##   #      ### #   #   ###  ##   #  

		if = {
			limit = {
				has_completed_focus = SPA_a_great_spain
			}
			hidden_effect = {
				SPA = { # Switch the tag alias for SPA - it now becomes SPD - the republicans
					clr_country_flag = SPR_nationalist_spain_flag
					drop_cosmetic_tag = yes
					set_country_flag = SPR_republican_spain_flag
					if = {
						limit = {
							has_game_rule = {
								rule = spr_fragmentation_status
								option = SPR_EU4
							}
						}
						set_cosmetic_tag = SPR_republican_castille
					}
					else = {
						set_cosmetic_tag = SPR_republican_spain
					}
					set_politics = {
						ruling_party = democratic
					}
					set_popularities = {
						democratic = 50
						neutrality = 11
						communism = 39
					}
					#retire_ideology_leader = democratic
					retire_ideology_leader = neutrality
					retire_ideology_leader = communism
				}
				SPD = { # Remove Carlist/Falangist country leaders for new SPD tag
					retire_ideology_leader = fascism
					retire_ideology_leader = neutrality
					every_possible_country = {
						limit = {
							has_character = SPR_manuel_azana	
						}
						SPR_manuel_azana = { set_nationality = SPD }
					}
					IF = {
						limit = {
							NOT = {
								has_country_leader = {
									character = SPR_manuel_azana
									ruling_only = yes
								}
							}
						}
						IF = {
							limit = {
								NOT = {
									can_be_country_leader = SPR_manuel_azana
								}
							}
							add_country_leader_role = {
								character = SPR_manuel_azana
								country_leader = {
								 	ideology = conservatism
								 	traits = { figurehead_president }
								 	expire = "1965.1.1"
								}
								promote_leader = yes
							}
						}
						ELSE = {
							promote_character = {
							    character = SPR_manuel_azana
							    ideology = conservatism
							}
						}
					}
				}
				# Switch the tag alias for the player's country - the player goes from SPR to SPA
				set_country_flag = SPR_nationalist_spain_flag
				if = {
					limit = {
						has_game_rule = {
							rule = spr_fragmentation_status
							option = SPR_EU4
						}
					}
					set_cosmetic_tag = SPR_nationalist_castille
				}
				else = {
					set_cosmetic_tag = SPR_nationalist_spain
				}
				set_politics = {
					ruling_party = neutrality
				}
				add_popularity = {
				    ideology = democratic
				    popularity = -0.25
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.1
				}
				kill_country_leader = yes
				create_country_leader = {
					name = "José Sanjurjo"
					desc = "POLITICS_JOSE_SANJURJO_DESC"
					picture = "GFX_portrait_SPA_jose_sanjurjo"
					expire = "1965.1.1"
					ideology = despotism
					traits = {
						the_lion_of_the_rif
					}
				}
				# Add Nationalist and Republican Garrison division templates
				division_template = {
					name = "Guarnición Nacionalista"
					is_locked = yes
					template_counter = 6
					division_names_group = SPR_INF_02
					regiments = {
						infantry = { x = 0 y = 0 }
						infantry = { x = 0 y = 1 }
						infantry = { x = 0 y = 2 }
					}
				}
				SPD = {
					division_template = {
						name = "Guarnición Republicana"
						is_locked = yes
						template_counter = 6
						division_names_group = SPD_INF_01
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
						}
					}
				}
				# Give SPD Madrid if the Nationalists don't have complete garrison control over it - becomes capital
				if = {
					limit = {
						41 = {
							check_variable = { var = SPA_garrison_control value = 1 compare = equals }
						}
					}
					SPD = {
						transfer_state = 41
					}
					41 = {
						set_state_flag = SPR_sided_with_republicans_flag
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 3
						}
					}
				}
				else_if = {
					limit = {
						41 = {
							check_variable = { var = SPA_garrison_control value = 2 compare = equals }
						}
					}
					SPD = {
						transfer_state = 41
					}
					41 = {
						set_state_flag = SPR_sided_with_republicans_flag
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
				}
				else_if = {
					limit = {
						41 = {
							check_variable = { var = SPA_garrison_control value = 3 compare = equals }
						}
					}
					SPD = {
						transfer_state = 41
					}
					41 = {
						set_state_flag = SPR_sided_with_republicans_flag
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
				}
				# If Madrid is controlled by Nationalists, but a random state exists that has total Republican garrison control, give that as capital first
				if = {
					limit = {
						41 = {
							check_variable = { var = SPA_garrison_control value = 4 compare = equals }
						}
						any_owned_state = {
							check_variable = { var = SPA_garrison_control value = 1 compare = equals }
						}
					}
					random_owned_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 1 compare = equals }
						}
						SPD = {
							transfer_state = PREV
						}
						set_state_flag = SPR_sided_with_republicans_flag
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 3
						}
					}
				}
				# Give a state that does not have total Nationalist garrison control to the Republicans as their capital - in decreasing order of Republican control
				else_if = {
					limit = {
						41 = {
							check_variable = { var = SPA_garrison_control value = 4 compare = equals }
						}
						any_owned_state = {
							check_variable = { var = SPA_garrison_control value = 2 compare = equals }
						}
					}
					random_owned_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = equals }
						}
						SPD = {
							transfer_state = PREV
						}
						set_state_flag = SPR_sided_with_republicans_flag
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
				}
				else_if = {
					limit = {
						41 = {
							check_variable = { var = SPA_garrison_control value = 4 compare = equals }
						}
						any_owned_state = {
							check_variable = { var = SPA_garrison_control value = 3 compare = equals }
						}
					}
					random_owned_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = equals }
						}
						SPD = {
							transfer_state = PREV
						}
						set_state_flag = SPR_sided_with_republicans_flag
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
				}
				# Split equipment and army/navy depending on which focuses the Republicans have finished
				if = {
					limit = {
						NOT = { has_country_flag = SPR_enlarge_the_weapon_caches_flag }
					}
					transfer_units_fraction = {
						target = SPD
						size = 0.5 # Fallback in case one of the ratios below are not stipulated
						stockpile_ratio = 0.5
						army_ratio = 0.5
						navy_ratio = 0.5
						air_ratio = 0.5
						keep_unit_leaders = {
						    
						}
						keep_unit_leaders_trigger = {
							has_trait = trait_SPA_nationalist_sympathies
						}
					}
				}
				if = {
					limit = {
						has_country_flag = SPR_enlarge_the_weapon_caches_flag
						NOT = { has_country_flag = SPR_disband_the_army_flag }
					}
					transfer_units_fraction = {
						target = SPD
						size = 0.5
						stockpile_ratio = 0.8
						army_ratio = 0.5
						navy_ratio = 0.5
						air_ratio = 0.5
						keep_unit_leaders = {
						    
						}
						keep_unit_leaders_trigger = {
							has_trait = trait_SPA_nationalist_sympathies
						}
					}
				}
				if = {
					limit = {
						has_country_flag = SPR_disband_the_army_flag
					}
					transfer_units_fraction = {
						target = SPD
						size = 0.5
						stockpile_ratio = 0.8
						army_ratio = 0.8
						navy_ratio = 0.5
						air_ratio = 0.5
						keep_unit_leaders = {
						    
						}
						keep_unit_leaders_trigger = {
							has_trait = trait_SPA_nationalist_sympathies
						}
					}
				}
				# If player has completed this focus, give North Africa and spawn units there (this effect is run first so the tag has any territory whatsoever - it's assumed all players take this focus)
				if = {
					limit = {
						has_completed_focus = SPA_the_army_of_africa
					}
					division_template = {
						name = "División del Ejército de África"
						template_counter = 4
						division_names_group = SPR_INF_06
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
							infantry = { x = 1 y = 0 }
							infantry = { x = 1 y = 1 }
							infantry = { x = 1 y = 2 }
							infantry = { x = 2 y = 0 }
							artillery_brigade = { x = 3 y = 0 }
							artillery_brigade = { x = 3 y = 1 }
						}
						support = {
							recon = { x = 0 y = 0 }
							engineer = { x = 0 y = 1 }
						}
					}
					290 = {
						create_unit = {
							division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
							owner = SPA
						}
						create_unit = {
							division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
							owner = SPA
						}
						create_unit = {
							division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
							owner = SPA
						}
						if = {
							limit = {
								ROOT = { NOT = { has_country_flag = SPR_disband_the_army_flag } }
							}
							create_unit = {
								division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
								owner = SPA
							}
							create_unit = {
								division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
								owner = SPA
							}
						}
					}
				}
				# Republicans remove their army
				SPD = {
					delete_units = {
					    division_template = "División de Infantería"
					    disband = yes
					}
					delete_units = {
					    division_template = "División de Caballería"
					    disband = yes
					}
					delete_units = {
					    division_template = "Brigada Montaña"
					    disband = yes
					}
					delete_units = {
					    division_template = "Brigada de Infantería"
					    disband = yes
					}
				}
				# Switch leaders who do not have nationalist sympathies to the Republicans
				every_unit_leader = {
					limit = {
						NOT = { has_trait = trait_SPA_nationalist_sympathies }
					}
					set_nationality = SPD
				}
				# Remove unnecessary traits from Nationalist commanders (no longer relevant to see for the player, as the SCW has started)
				every_unit_leader = {
					limit = {
						has_trait = trait_SPA_nationalist_sympathies
					}
					remove_unit_leader_trait = trait_SPA_nationalist_sympathies
				}
				# Add various loyalist traits that now become relevant - indicating loyalties to the different subfactions
				every_unit_leader = {
					limit = {
						OR = {
							has_id = 1108
							has_id = 1109
							has_id = 1111
							has_id = 1112
							has_id = 1113
						}
					}
					add_unit_leader_trait = trait_SPA_falangist_loyalties
				}
				every_unit_leader = {
					limit = {
						OR = {
							has_id = 1114
							has_id = 1115
							has_id = 1116
						}
					}
					add_unit_leader_trait = trait_SPA_carlist_loyalties
				}
				SPD = {
					every_unit_leader = {
						limit = {
							OR = {
								has_id = 1101
								has_id = 1102
								has_id = 1103
							}
						}
						add_unit_leader_trait = trait_SPR_republican_loyalties
					}
					every_unit_leader = {
						limit = {
							OR = {
								has_id = 1104
								has_id = 1105
								has_id = 1106
								is_character = SPR_enrique_lister
							}
						}
						add_unit_leader_trait = trait_SPR_stalinist_loyalties
					}
					every_unit_leader = {
						limit = {
							OR = {
								has_id = 1107
							}
						}
						add_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
					}
				}
				# Add 3 Republican garrisons to every state where the Nationalists have NONE control
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 1 compare = equals }
						NOT = {
							state = 290
							state = 699
							state = 783
							state = 297
						}
					}
					# Transfer states and set flag to prepare for post-Civil War de-coring
					SPD = {
						transfer_state = PREV
					}
					set_state_flag = SPR_sided_with_republicans_flag
					create_unit = {
						division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
						owner = SPD
						allow_spawning_on_enemy_provs = yes
						count = 3
					}
				}
				41 = { # Extra 6 divisions to make Madrid harder to capture (as historically)
					create_unit = {
						division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
						owner = SPD
						allow_spawning_on_enemy_provs = yes
						count = 6
					}
				}
				# Add 3 Nationalist garrisons to every state where the Nationalists have TOTAL control
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 4 compare = equals }
					}
					create_unit = {
						division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
						owner = SPA
						allow_spawning_on_enemy_provs = yes
						count = 3
					}
				}
				# Trigger war between the sides - necessary because the next effects spawn units on contested provinces and this requires both sides to be at war
				SPA = {
					declare_war_on = {
					    target = SPD
					    type = civil_war
					}
					add_civil_war_target = SPD
				}
				# 2 Republican and 1 Nationalist garrisons spawned on all states with WEAK Nationalist control (except for Northern Garrison states)
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 2 compare = equals }
						NOT = { has_state_flag = SPA_northern_garrisons_state_flag }
					}
					# Transfer states and set flag to prepare for post-Civil War de-coring
					SPD = {
						transfer_state = PREV
					}
					set_state_flag = SPR_sided_with_republicans_flag
					create_unit = {
						division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
						owner = SPD
						allow_spawning_on_enemy_provs = yes
						count = 2
					}
					create_unit = {
						division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
						owner = SPA
						allow_spawning_on_enemy_provs = yes
						count = 1
					}
				}
				# 2 Nationalist and 1 Republican garrisons spawned on all states with STRONG Nationalist control
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 3 compare = equals }
						NOT = { has_state_flag = SPA_northern_garrisons_state_flag }
					}
					# Transfer states and set flag to prepare for post-Civil War de-coring
					SPD = {
						transfer_state = PREV
					}
					set_state_flag = SPR_sided_with_republicans_flag
					create_unit = {
						division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
						owner = SPD
						allow_spawning_on_enemy_provs = yes
						count = 1
					}
					create_unit = {
						division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
						owner = SPA
						allow_spawning_on_enemy_provs = yes
						count = 2
					}
				}
				# If Negotiate Carlist Support has been taken, add Nationalist units in Navarra
				if = {
					limit = {
						has_country_flag = SPA_negotiate_carlist_support_flag
						OR = {
							is_ai = no
							is_historical_focus_on = no
						}
					}
					division_template = {
						name = "Requeté Carlista"
						template_counter = 8
						division_names_group = SPR_INF_03
						is_locked = yes
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
						}
					}
					172 = {
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 5
						}
					}
				}
				# If Negotiate Carlist Support has been taken AND AI, add Nationalist units in Navarra AND Western Aragon
				if = {
					limit = {
						has_country_flag = SPA_negotiate_carlist_support_flag
						is_ai = yes
						is_historical_focus_on = yes
					}
					division_template = {
						name = "Requeté Carlista"
						template_counter = 8
						division_names_group = SPR_INF_03
						is_locked = yes
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
						}
					}
					172 = {
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					166 = {
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
							owner = SPA
							prioritize_location = 3816
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
				}
				# If Republicans secured the Guardia Civil, add Civil divisions to random states for the Republicans, and Asalto divisions to random states for the Nationalists
				if = {
					limit = {
						has_country_flag = SPR_secure_the_guardia_civil_flag
					}
					division_template = {
						name = "División de la Guardia de Asalto"
						template_counter = 5
						division_names_group = SPR_INF_05
						is_locked = yes
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
							infantry = { x = 1 y = 0 }
							infantry = { x = 1 y = 1 }
							infantry = { x = 1 y = 2 }
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
					}
					SPD = {
						division_template = {
							name = "Brigada de la Guardia Civil"
							template_counter = 7
							division_names_group = SPR_INF_04
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
				}
				# If Republicans secured the Guardia de Asalto, do the opposite distribution
				else_if = {
					limit = {
						has_country_flag = SPR_secure_the_guardia_de_asalto_flag
					}
					division_template = {
						name = "Brigada de la Guardia Civil"
						template_counter = 7
						division_names_group = SPR_INF_04
						is_locked = yes
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
					SPD = {
						division_template = {
							name = "División de la Guardia de Asalto"
							template_counter = 5
							division_names_group = SPR_INF_05
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
								infantry = { x = 1 y = 0 }
								infantry = { x = 1 y = 1 }
								infantry = { x = 1 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
							}
						}
					}
				}
				else = { #Extra backup in case player never took any focuses - SPA gets BOTH types! Suck on it, Reds!
					division_template = {
						name = "División de la Guardia de Asalto"
						template_counter = 5
						division_names_group = SPR_INF_05
						is_locked = yes
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
							infantry = { x = 1 y = 0 }
							infantry = { x = 1 y = 1 }
							infantry = { x = 1 y = 2 }
						}
					}
					division_template = {
						name = "Brigada de la Guardia Civil"
						template_counter = 7
						division_names_group = SPR_INF_04
						is_locked = yes
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
						}
					}
	
					#Guardia de Asalto
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
					}
	
					# Guardia Civil
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
				}
				# If Republicans had time to Train the Union Youth, add these divisions to random states that have at MOST WEAK Nationalist control
				if = {
					limit = {
						has_country_flag = SPR_train_the_union_youth_flag
					}
					SPD = {
						division_template = {
							name = "Brigada de Juventudes Sindicales"
							template_counter = 0
							division_names_group = SPD_INF_02
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						if = {
							limit = {
								difficulty > 1
								ROOT = {
									is_ai = no
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						if = {
							limit = {
								difficulty > 1
								ROOT = {
									is_ai = no
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						if = {
							limit = {
								difficulty > 1
								ROOT = {
									is_ai = no
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						if = {
							limit = {
								difficulty > 1
								ROOT = {
									is_ai = no
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						if = {
							limit = {
								difficulty > 1
								ROOT = {
									is_ai = no
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
				}
				# If Republicans had time to Distribute Arms to the People, add these divisions to random states that have at MOST WEAK Nationalist control
				if = {
					limit = {
						has_country_flag = SPR_distribute_arms_to_the_people_flag
					}
					SPD = {
						division_template = {
							name = "Brigada Popular"
							template_counter = 13
							division_names_group = SPD_INF_03
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
				}
				# Load Spanish FT for Republicans, unlock relevant focuses
				SPD = {
					load_focus_tree = {
						tree = spanish_focus
						keep_completed = no
					}
					unlock_national_focus = SPR_the_popular_front
				}
				# Randomize which one they get, unless they had time to pick one
				random_list = {
					10 = {
						modifier = {
							factor = 0
							has_country_flag = SPR_secure_the_guardia_civil_flag
						}
						SPD = { unlock_national_focus = SPR_secure_the_guardia_de_asalto }
					}
					10 = {
						modifier = {
							factor = 0
							has_country_flag = SPR_secure_the_guardia_de_asalto_flag
						}
						SPD = { unlock_national_focus = SPR_secure_the_guardia_civil }
					}
				}
				SPD = {
					unlock_national_focus = SPR_train_the_union_youth
					unlock_national_focus = SPR_enlarge_the_weapon_caches
					unlock_national_focus = SPR_distribute_arms_to_the_people
					unlock_national_focus = SPR_disband_the_army
					random_list = {
						10 = {
							modifier = {
								factor = 0
								is_historical_focus_on = yes
							}
							modifier = {
								factor = 0
								has_global_flag = SOV_covert_support_for_poum_flag #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
							}
							complete_national_focus = SPR_regional_defense_council_of_aragon
						}
						10 = {
							modifier = {
								factor = 0
								has_global_flag = SOV_covert_support_for_poum_flag #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
							}
							complete_national_focus = SPR_maintain_the_second_republic
						}
						10 = {
							modifier = {
								factor = 0
								is_historical_focus_on = yes
							}
							modifier = {
								add = 10
								has_global_flag = SOV_covert_support_for_poum_flag #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
							}
							complete_national_focus = SPR_the_anti_fascist_workers_revolution
						}
					}
				}
				# Unlock division templates for Nationalists
				country_lock_all_division_template = no
				every_owned_state = {
					set_state_flag = SPR_sided_with_nationalists_flag
				}
				if = {
					limit = {
						176 = { is_owned_by = ROOT }
					}
					set_capital = { state = 176 }
				}
				else_if = {
					limit = {
						171 = { is_owned_by = ROOT }
					}
					set_capital = { state = 171 }
				}
				else = {
					random_owned_state = {
						ROOT = { set_capital = { state = PREV } }
					}
				}
				# Unlock division templates for Republicans
				SPD = {
					every_state = {
						limit = {
							has_state_flag = SPR_core_of_spain_flag
						}
						add_core_of = SPD
					}
					inherit_technology = SPA
					country_lock_all_division_template = no
				}
				if = {
					limit = {
						41 = { is_owned_by = SPD }
					}
					SPD = { set_capital = { state = 41 } }
				}
				else_if = {
					limit = {
						165 = { is_owned_by = SPD }
					}
					SPD = { set_capital = { state = 165 } }
				}
				else = {
					random_owned_state = {
						SPD = { set_capital = { state = PREV } }
					}
				}
				# We need to teleport the railway guns after capitals have been set. transfer_units_fraction will
				# teleport them but to the wrong province.
				teleport_railway_guns_to_deploy_province = ROOT
				teleport_railway_guns_to_deploy_province = SPD
				SPD = {
					add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
					add_ideas = SPR_disbanded_army_1
					set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
				}
				set_party_name = { ideology = neutrality long_name = SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party }
				#every_unit_leader = {
				#	limit = {
				#		has_unit_leader_flag = SPR_reassigned_flag
				#	}
				#	ROOT = { remove_unit_leader = PREV }
				#}
				add_timed_idea = { idea = SPA_death_before_surrender days = 900 }
				set_global_flag = spanish_civil_war # Start civil war - used in many triggers
				country_event = { id = lar_spain.6 days = 7 } # SCW notification event for the player
				country_event = { id = lar_spain.78 days = 7 random_days = 7 } # Sanjurjo dies
			}
		}

###  ### ###  #  # ###  #   ###  ##   ##  #  #     ### ### ### ###  ##  ### 
#  # #   #  # #  # #  # #    #  #  # #  # ## #     #   #   #   #   #  #  #  
###  ##  ###  #  # ###  #    #  #    #### # ##     ##  ##  ##  ##  #     #  
#  # #   #    #  # #  # #    #  #  # #  # #  #     #   #   #   #   #  #  #  
#  # ### #     ##  ###  ### ###  ##  #  # #  #     ### #   #   ###  ##   #  

		# check Nationalist effect for detailed comments
		if = {
			limit = {
				has_completed_focus = SPR_the_popular_front
			}
			hidden_effect = {
				set_country_flag = SPR_republican_spain_flag
				if = {
					limit = {
						has_game_rule = {
							rule = spr_fragmentation_status
							option = SPR_EU4
						}
					}
					set_cosmetic_tag = SPR_republican_castille
				}
				else = {
					set_cosmetic_tag = SPR_republican_spain
				}
				SPA = {
					retire_ideology_leader = democratic
					retire_ideology_leader = neutrality
					retire_ideology_leader = communism
					kill_country_leader = yes
					create_country_leader = {
						name = "José Sanjurjo"
						desc = "POLITICS_JOSE_SANJURJO_DESC"
						picture = "GFX_portrait_SPA_jose_sanjurjo"
						expire = "1965.1.1"
						ideology = despotism
						traits = {
							the_lion_of_the_rif
						}
					}
					set_popularities = {
						democratic = 5
						communism = 3
						neutrality = 44
						fascism = 48
					}
					transfer_state = 177
					177 = { set_state_flag = SPR_sided_with_nationalists_flag }
					transfer_state = 178
					178 = { set_state_flag = SPR_sided_with_nationalists_flag }
				}
				SPD = {
					retire_ideology_leader = fascism
					retire_ideology_leader = neutrality
					IF = {
						limit = {
							NOT = {
								has_country_leader = {
									character = SPR_manuel_azana
									ruling_only = yes
								}
							}
						}
						IF = {
							limit = {
								NOT = {
									can_be_country_leader = SPR_manuel_azana
								}
							}
							add_country_leader_role = {
								character = SPR_manuel_azana
								country_leader = {
								 	ideology = conservatism
								 	traits = { figurehead_president }
								 	expire = "1965.1.1"
								}
								promote_leader = yes
							}
						}
						ELSE = {
							promote_character = {
							    character = SPR_manuel_azana
							    ideology = conservatism
							}
						}
					}
				}
				add_popularity = {
				    ideology = fascism
				    popularity = -0.3
				}
				add_popularity = {
				    ideology = neutrality
				    popularity = -0.2
				}
				division_template = {
					name = "Guarnición Republicana"
					is_locked = yes
					template_counter = 6
					division_names_group = SPD_INF_01
					regiments = {
						infantry = { x = 0 y = 0 }
						infantry = { x = 0 y = 1 }
						infantry = { x = 0 y = 2 }
					}
				}
				SPA = {
					division_template = {
						name = "Guarnición Nacionalista"
						is_locked = yes
						template_counter = 6
						division_names_group = SPR_INF_02
						regiments = {
							infantry = { x = 0 y = 0 }
							infantry = { x = 0 y = 1 }
							infantry = { x = 0 y = 2 }
						}
					}
				}
				if = {
					limit = {
						has_country_flag = SPA_the_army_of_africa_flag
					}
					SPA = {
						transfer_state = 290
						290 = { set_state_flag = SPR_sided_with_nationalists_flag }
						division_template = {
							name = "División del Ejército de África"
							template_counter = 4
							division_names_group = SPR_INF_06
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
								infantry = { x = 1 y = 0 }
								infantry = { x = 1 y = 1 }
								infantry = { x = 1 y = 2 }
								infantry = { x = 2 y = 0 }
								artillery_brigade = { x = 2 y = 1 }
								artillery_brigade = { x = 2 y = 2 }
							}
							support = {
								recon = { x = 0 y = 0 }
								engineer = { x = 0 y = 1 }
							}
						}
						290 = {
							create_unit = {
								division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
								owner = SPA
							}
							create_unit = {
								division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
								owner = SPA
							}
							create_unit = {
								division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
								owner = SPA
							}
							if = {
								limit = {
									ROOT = { NOT = { has_country_flag = SPR_disband_the_army_flag } }
								}
								create_unit = {
									division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
									owner = SPA
								}
								create_unit = {
									division = "division_template = \"División del Ejército de África\" start_experience_factor = 0.3" 
									owner = SPA
								}
							}
						}
					}
				}
				if = {
					limit = {
						NOT = { has_completed_focus = SPR_enlarge_the_weapon_caches }
					}
					transfer_units_fraction = {
						target = SPA
						size = 0.5 # Fallback in case one of the ratios below are not stipulated
						stockpile_ratio = 0.5
						army_ratio = 0.5
						navy_ratio = 0.5
						air_ratio = 0.5
						keep_unit_leaders = {
						    
						}
						keep_unit_leaders_trigger = {
							NOT = { has_trait = trait_SPA_nationalist_sympathies }
						}
					}
				}
				if = {
					limit = {
						has_completed_focus = SPR_enlarge_the_weapon_caches
						NOT = { has_completed_focus = SPR_disband_the_army }
					}
					transfer_units_fraction = {
						target = SPA
						size = 0.5
						stockpile_ratio = 0.2
						army_ratio = 0.5
						navy_ratio = 0.5
						air_ratio = 0.5
						keep_unit_leaders = {
						    
						}
						keep_unit_leaders_trigger = {
							NOT = { has_trait = trait_SPA_nationalist_sympathies }
						}
					}
				}
				if = {
					limit = {
						has_completed_focus = SPR_disband_the_army
					}
					transfer_units_fraction = {
						target = SPA
						size = 0.5
						stockpile_ratio = 0.2
						army_ratio = 0.2
						navy_ratio = 0.5
						air_ratio = 0.5
						keep_unit_leaders = {
						    
						}
						keep_unit_leaders_trigger = {
							NOT = { has_trait = trait_SPA_nationalist_sympathies }
						}
					}
				}
				delete_units = {
				    division_template = "División de Infantería"
				    disband = yes
				}
				delete_units = {
				    division_template = "División de Caballería"
				    disband = yes
				}
				delete_units = {
				    division_template = "Brigada Montaña"
				    disband = yes
				}
				delete_units = {
				    division_template = "Brigada de Infantería"
				    disband = yes
				}
				every_unit_leader = {
					limit = {
						has_trait = trait_SPA_nationalist_sympathies
					}
					remove_unit_leader_trait = trait_SPA_nationalist_sympathies
					set_nationality = SPA
				}
				SPA = {
					every_unit_leader = {
						limit = {
							OR = {
								has_id = 1108
								has_id = 1109
								has_id = 1111
								has_id = 1112
								has_id = 1113
							}
						}
						remove_unit_leader_trait = trait_SPA_nationalist_sympathies
						add_unit_leader_trait = trait_SPA_falangist_loyalties
					}
					every_unit_leader = {
						limit = {
							OR = {
								has_id = 1114
								has_id = 1115
								has_id = 1116
							}
						}
						remove_unit_leader_trait = trait_SPA_nationalist_sympathies
						add_unit_leader_trait = trait_SPA_carlist_loyalties
					}
					every_unit_leader = {
						limit = {
							has_id = 1110
						}
						remove_unit_leader_trait = trait_SPA_nationalist_sympathies
					}
				}
				every_unit_leader = {
					limit = {
						OR = {
							has_id = 1101
							has_id = 1102
							has_id = 1103
						}
					}
					add_unit_leader_trait = trait_SPR_republican_loyalties
				}
				every_unit_leader = {
					limit = {
						OR = {
							has_id = 1104
							has_id = 1105
							has_id = 1106
						}
					}
					add_unit_leader_trait = trait_SPR_stalinist_loyalties
				}
				every_unit_leader = {
					limit = {
						OR = {
							has_id = 1107
						}
					}
					add_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
				}
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 1 compare = equals }
						NOT = {
							state = 290
							state = 699
							state = 783
							state = 297
						}
					}
					create_unit = {
						division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
						owner = SPD
						allow_spawning_on_enemy_provs = yes
						count = 3
					}
				}
				41 = { # Extra 6 divisions to make Madrid harder to capture (as historically)
					create_unit = {
						division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
						owner = SPD
						allow_spawning_on_enemy_provs = yes
						count = 6
					}
				}
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 4 compare = equals }
					}
					SPA = {
						transfer_state = PREV
					}
					set_state_flag = SPR_sided_with_nationalists_flag
					create_unit = {
						division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
						owner = SPA
						allow_spawning_on_enemy_provs = yes
						count = 3
					}
				}
				SPA = {
					declare_war_on = {
					    target = SPD
					    type = civil_war
					}
					add_civil_war_target = SPD
				}
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 2 compare = equals }
					}
					if = {
						limit = {
							has_state_flag = SPA_northern_garrisons_state_flag
						}
						SPA = {
							transfer_state = PREV
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					else = {
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
				}
				every_owned_state = {
					limit = {
						check_variable = { var = SPA_garrison_control value = 3 compare = equals }
					}
					if = {
						limit = {
							has_state_flag = SPA_northern_garrisons_state_flag
						}
						SPA = {
							transfer_state = PREV
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					else = {
						create_unit = {
							division = "division_template = \"Guarnición Republicana\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
						create_unit = {
							division = "division_template = \"Guarnición Nacionalista\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
				}
				if = {
					limit = {
						has_country_flag = SPA_negotiate_carlist_support_flag
					}
					SPA = {
						division_template = {
							name = "Requeté Carlista"
							template_counter = 8
							division_names_group = SPR_INF_03
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					172 = {
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.5" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 5
						}
						if = {
							limit = {
								difficulty > 1
								ROOT = {
									is_ai = no
								}
							}
							create_unit = {
								division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.5" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 5
							}
						}
					}
				}
				if = {
					limit = {
						has_completed_focus = SPR_secure_the_guardia_civil
					}
					SPA = {
						division_template = {
							name = "División de la Guardia de Asalto"
							template_counter = 5
							division_names_group = SPR_INF_05
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
								infantry = { x = 1 y = 0 }
								infantry = { x = 1 y = 1 }
								infantry = { x = 1 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
					}
					SPD = {
						division_template = {
							name = "Brigada de la Guardia Civil"
							template_counter = 7
							division_names_group = SPR_INF_04
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
				}
				else_if = {
					limit = {
						has_completed_focus = SPR_secure_the_guardia_de_asalto
					}
					SPA = {
						division_template = {
							name = "Brigada de la Guardia Civil"
							template_counter = 7
							division_names_group = SPR_INF_04
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
					SPD = {
						division_template = {
							name = "División de la Guardia de Asalto"
							template_counter = 5
							division_names_group = SPR_INF_05
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
								infantry = { x = 1 y = 0 }
								infantry = { x = 1 y = 1 }
								infantry = { x = 1 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
								check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
								if = {
									limit = {
										ROOT = {
											is_ai = yes
											OR = {
												AND = {
													is_historical_focus_on = yes
													has_game_rule = {
														rule = SPR_ai_behavior 
														option = DEFAULT
													}
												}
												has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = NATIONALIST_HISTORICAL
												}
											}
										}
									}
									NOT = {
										state = 790
										state = 792
									}
								}
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPD
								allow_spawning_on_enemy_provs = yes
							}
						}
					}
				}
				else = { #Extra backup in case player never took any focuses - SPA gets BOTH types!
					SPA = {
						division_template = {
							name = "División de la Guardia de Asalto"
							template_counter = 5
							division_names_group = SPR_INF_05
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
								infantry = { x = 1 y = 0 }
								infantry = { x = 1 y = 1 }
								infantry = { x = 1 y = 2 }
							}
						}
						division_template = {
							name = "Brigada de la Guardia Civil"
							template_counter = 7
							division_names_group = SPR_INF_04
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
	
					#Guardia de Asalto
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"División de la Guardia de Asalto\" start_experience_factor = 0.3" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
							}
						}
					}
	
					# Guardia Civil
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
						create_unit = {
							division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
							owner = SPA
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					if = {
						limit = {
							difficulty > 1
							ROOT = {
								is_ai = no
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
						random_state = {
							limit = {
								check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
							}
							create_unit = {
								division = "division_template = \"Brigada de la Guardia Civil\" start_experience_factor = 0.1" 
								owner = SPA
								allow_spawning_on_enemy_provs = yes
								count = 1
							}
						}
					}
				}
				if = {
					limit = {
						has_completed_focus = SPR_train_the_union_youth
					}
					SPD = {
						division_template = {
							name = "Brigada de Juventudes Sindicales"
							template_counter = 0
							division_names_group = SPD_INF_02
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada de Juventudes Sindicales\" start_experience_factor = 0.2" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 1
						}
					}
				}
				if = {
					limit = {
						has_completed_focus = SPR_distribute_arms_to_the_people
					}
					SPD = {
						division_template = {
							name = "Brigada Popular"
							template_counter = 13
							division_names_group = SPD_INF_03
							is_locked = yes
							regiments = {
								infantry = { x = 0 y = 0 }
								infantry = { x = 0 y = 1 }
								infantry = { x = 0 y = 2 }
							}
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
					random_state = {
						limit = {
							check_variable = { var = SPA_garrison_control value = 2 compare = less_than_or_equals }
							check_variable = { var = SPA_garrison_control value = 1 compare = greater_than_or_equals }
							if = {
								limit = {
									ROOT = {
										is_ai = yes
										OR = {
											AND = {
												is_historical_focus_on = yes
												has_game_rule = {
													rule = SPR_ai_behavior 
													option = DEFAULT
												}
											}
											has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
											has_game_rule = {
												rule = SPR_ai_behavior 
												option = NATIONALIST_HISTORICAL
											}
										}
									}
								}
								NOT = {
									state = 790
									state = 792
								}
							}
						}
						create_unit = {
							division = "division_template = \"Brigada Popular\" start_experience_factor = 0" 
							owner = SPD
							allow_spawning_on_enemy_provs = yes
							count = 2
						}
					}
				}
				SPA = {
					load_focus_tree = {
						tree = spanish_focus
						keep_completed = no
					}
					unlock_national_focus = SPA_a_great_spain
					unlock_national_focus = SPA_hand_over_the_ceda_campaign_chest
					unlock_national_focus = SPA_negotiate_carlist_support
					unlock_national_focus = SPA_the_army_of_africa
					unlock_national_focus = SPA_secure_the_northern_garrisons
					random_list = {
						10 = {
							modifier = {
								factor = 0
								ROOT = { has_country_flag = SPA_con_paquito_flag }
							}
							unlock_national_focus = SPA_sin_paquito
						}
						10 = {
							modifier = {
								factor = 0
								ROOT = { has_country_flag = SPA_sin_paquito_flag }
							}
							unlock_national_focus = SPA_con_paquito
						}
					}
					random_list = {
						10 = {
							modifier = {
								factor = 0
								is_historical_focus_on = yes
							}
							modifier = {
								factor = 0
								ROOT = { has_country_flag = SPA_con_paquito_flag }
							}
							complete_national_focus = SPA_the_phalanx_ascendant
						}
						10 = {
							modifier = {
								factor = 0
								ROOT = { has_country_flag = SPA_sin_paquito_flag }
							}
							complete_national_focus = SPA_unify_the_nationalist_front
						}
						10 = {
							modifier = {
								factor = 0
								is_historical_focus_on = yes
							}
							complete_national_focus = SPA_supremacy_of_the_communion
						}
					}
					add_ideas = SPA_carlism_1
				}
				country_lock_all_division_template = no
				every_owned_state = {
					set_state_flag = SPR_sided_with_republicans_flag
				}
				if = {
					limit = {
						41 = { is_owned_by = ROOT }
					}
					set_capital = { state = 41 }
				}
				else_if = {
					limit = {
						165 = { is_owned_by = ROOT }
					}
					set_capital = { state = 165 }
				}
				else = {
					random_owned_state = {
						ROOT = { set_capital = { state = PREV } }
					}
				}
				SPA = {
					every_state = {
						limit = {
							has_state_flag = SPR_core_of_spain_flag
						}
						add_core_of = SPA
					}
					inherit_technology = SPD
					country_lock_all_division_template = no
					if = {
						limit = {
							176 = { is_owned_by = SPA }
						}
						SPA = { set_capital = { state = 176 } }
					}
					else_if = {
						limit = {
							171 = { is_owned_by = SPA }
						}
						SPA = { set_capital = { state = 171 } }
					}
					else = {
						random_owned_state = {
							SPA = { set_capital = { state = PREV } }
						}
					}
					set_party_name = { ideology = neutrality long_name = SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party }
				}
				# We need to teleport the railway guns after capitals have been set. transfer_units_fraction will
				# teleport them but to the wrong province.
				teleport_railway_guns_to_deploy_province = ROOT
				teleport_railway_guns_to_deploy_province = SPA
				set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
				SPA = { add_timed_idea = { idea = SPA_death_before_surrender days = 900 } }
				add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
				add_ideas = SPR_disbanded_army_1
				set_global_flag = spanish_civil_war
				country_event = { id = lar_spain.6 days = 7 }
				SPA = { country_event = { id = lar_spain.78 days = 7 random_days = 7 } } # Sanjurjo dies
			}
		}
		hidden_effect = {
			# Marks gui as "dirty" so the code updates the layout to properly hide the unused branches
			mark_focus_tree_layout_dirty = yes
		}
	}
	
	option = { # Option for Nationalists - Franco
		name = lar_spain.2.a
		trigger = { has_completed_focus = SPA_con_paquito }
		ai_chance = {
			base = 40
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_FALANGIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = FALANGIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_CARLIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = CARLIST
					}
				}
			}
		}
		# Remove Spirits that will no longer be relevant
		custom_effect_tooltip = nationalists_chosen
		remove_ideas = SPR_military_disloyalty
		remove_ideas = SPR_political_violence
		SPR_clr_national_strikes = yes
		effect_tooltip = {
			add_timed_idea = { idea = SPA_death_before_surrender days = 900 }
			SPD = { add_timed_idea = { idea = SPR_death_before_surrender days = 900 } }
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party }
			kill_ideology_leader = fascism
		}
		complete_national_focus = SPA_unify_the_nationalist_front
	}
	option = { # Option for Nationalists - Falangism
		name = lar_spain.2.b
		trigger = { has_completed_focus = SPA_sin_paquito }
		ai_chance = {
			base = 30
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_CARLIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = CARLIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					AND = {
						is_historical_focus_on = yes
						has_game_rule = {
							rule = SPR_ai_behavior 
							option = DEFAULT
						}
					}
					has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = NATIONALIST_HISTORICAL
					}
				}
			}
		}
		# Remove Spirits that will no longer be relevant
		custom_effect_tooltip = nationalists_chosen
		remove_ideas = SPR_military_disloyalty
		remove_ideas = SPR_political_violence
		SPR_clr_national_strikes = yes
		effect_tooltip = {
			add_timed_idea = { idea = SPA_death_before_surrender days = 900 }
			SPD = { add_timed_idea = { idea = SPR_death_before_surrender days = 900 } }
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party }
		}
		complete_national_focus = SPA_the_phalanx_ascendant
	}
	option = { # Option for Nationalists - Carlism
		name = lar_spain.2.c
		trigger = { has_completed_focus = SPA_a_great_spain }
		ai_chance = {
			base = 30
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_FALANGIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = FALANGIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					AND = {
						is_historical_focus_on = yes
						has_game_rule = {
							rule = SPR_ai_behavior 
							option = DEFAULT
						}
					}
					has_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = NATIONALIST_HISTORICAL
					}
				}
			}
		}
		# Remove Spirits that will no longer be relevant
		custom_effect_tooltip = nationalists_chosen
		remove_ideas = SPR_military_disloyalty
		remove_ideas = SPR_political_violence
		SPR_clr_national_strikes = yes
		effect_tooltip = {
			add_timed_idea = { idea = SPA_death_before_surrender days = 900 }
			SPD = { add_timed_idea = { idea = SPR_death_before_surrender days = 900 } }
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party }
			kill_ideology_leader = fascism
		}
		complete_national_focus = SPA_supremacy_of_the_communion
	}
	option = { # Option for Republicans - Democratic
		name = lar_spain.2.d
		trigger = { has_completed_focus = SPR_the_popular_front }
		ai_chance = {
			base = 40
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_ANARCHIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = ANARCHIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_INDEPENDENT_COMMUNIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = INDEPENDENT_COMMUNIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_STALINIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = STALINIST
					}
				}
			}
			modifier = {
				factor = 0
				has_global_flag = SOV_covert_support_for_poum_flag #Soviet Right Opposition is providing support to the POUM
			}
		}
		# Remove Spirits that will no longer be relevant
		custom_effect_tooltip = republicans_chosen
		remove_ideas = SPA_carlism_1
		remove_ideas = SPR_military_disloyalty
		remove_ideas = SPR_political_violence
		SPR_clr_national_strikes = yes
		effect_tooltip = {
			add_ideas = SPR_disbanded_army_1
		}
		effect_tooltip = {
			add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
			SPA = { add_timed_idea = { idea = SPA_death_before_surrender days = 900 } }
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
		}
		complete_national_focus = SPR_maintain_the_second_republic
	}
	option = { # Option for Republicans - Communism
		name = lar_spain.2.e
		trigger = { has_completed_focus = SPR_the_popular_front }
		ai_chance = {
			base = 30
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_ANARCHIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = ANARCHIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_SECOND_REPUBLIC
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = SECOND_REPUBLIC
					}
				}
			}
			modifier = {
				add = 30
				has_global_flag = SOV_covert_support_for_poum_flag #Soviet Right Opposition is providing support to the POUM
			}
		}
		# Remove Spirits that will no longer be relevant
		custom_effect_tooltip = republicans_chosen
		remove_ideas = SPA_carlism_1
		remove_ideas = SPR_military_disloyalty
		remove_ideas = SPR_political_violence
		SPR_clr_national_strikes = yes
		effect_tooltip = {
			add_ideas = SPR_disbanded_army_1
		}
		effect_tooltip = {
			add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
			SPA = { add_timed_idea = { idea = SPA_death_before_surrender days = 900 } }
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
		}
		complete_national_focus = SPR_the_anti_fascist_workers_revolution
	}
	option = { # Option for Republicans - Anarchism
		name = lar_spain.2.f
		trigger = { has_completed_focus = SPR_the_popular_front }
		ai_chance = {
			base = 30
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_SECOND_REPUBLIC
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = SECOND_REPUBLIC
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_INDEPENDENT_COMMUNIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = INDEPENDENT_COMMUNIST
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_country_flag = SPR_AI_RANDOM_STALINIST
					has_game_rule = {
						rule = SPR_ai_behavior 
						option = STALINIST
					}
				}
			}
			modifier = {
				factor = 0
				has_global_flag = SOV_covert_support_for_poum_flag #Soviet Right Opposition is providing support to the POUM
			}
		}
		# Remove Spirits that will no longer be relevant
		custom_effect_tooltip = republicans_chosen
		remove_ideas = SPA_carlism_1
		remove_ideas = SPR_military_disloyalty
		remove_ideas = SPR_political_violence
		SPR_clr_national_strikes = yes
		effect_tooltip = {
			add_ideas = SPR_disbanded_army_1
		}
		effect_tooltip = {
			add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
			SPA = { add_timed_idea = { idea = SPA_death_before_surrender days = 900 } }
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
		}
		complete_national_focus = SPR_regional_defense_council_of_aragon
	}
}

# Mission Generator simulating Republican government working against the Nationalists
country_event = {
	id = lar_spain.3

	trigger = {
		NOT = { has_global_flag = spanish_civil_war }
	}
	
	is_triggered_only = yes

	hidden = yes

	immediate = {
		random_list = {
			30 = { # Government imprisons Primo de Rivera
				modifier = {
					factor = 0
					OR = {
						NOT = { has_country_flag = SPR_primo_de_rivera_first_speech }
						has_country_flag = SPA_primo_de_rivera_imprisoned
					}
				}
				activate_mission = SPA_imprison_primo_de_rivera_mission
			}
			30 = { # Government makes political arrest
				modifier = {
					factor = 0
					NOT = { has_country_flag = SPA_political_assassination_flag }
				}
				activate_mission = SPA_political_arrest_mission
			}
			10 = { # Government reassigns disloyal general
				modifier = {
					factor = 0
					NOT = {
						any_army_leader = {
							has_trait = trait_SPA_nationalist_sympathies
							NOT = { has_unit_leader_flag = SPR_reassigned_flag }
						}
					}
				}
				activate_mission = SPA_reassign_disloyal_leader_mission
			}
			30 = { # Government makes concessions to the far left
				activate_mission = SPA_concessions_to_the_left_mission
			}
		}
	}
}

# Mission Generator simulating Nationalists working against the Republican Government
country_event = {
	id = lar_spain.4

	trigger = {
		NOT = { has_global_flag = spanish_civil_war }
	}
	
	is_triggered_only = yes

	hidden = yes

	immediate = {
		random_list = {
			35 = { # Primo de Rivera makes inflammatory speech
				activate_mission = SPR_primo_de_rivera_speech_mission
				modifier = {
					factor = 0
					has_country_flag = SPA_primo_de_rivera_imprisoned
				}
				modifier = {
					factor = 0
					has_decision = SPR_imprison_primo_de_rivera
				}
			}
			15 = { # Nationalists conduct political assassination
				activate_mission = SPR_political_assassination_mission
			}
			20 = { # Nationalists obtain general's loyalty
				activate_mission = SPR_sway_leader_loyalty_mission
				modifier = {
					factor = 0
					any_unit_leader = {
						has_unit_leader_flag = SPA_swayed_leader_loyalty_flag
					}
				}
			}
			30 = { # Nationalists suppress the leftist strikes
				activate_mission = SPR_suppress_the_strikes_mission
			}
		}
	}
}

# Mission Generator simulating other side expanding garrison influence
country_event = {
	id = lar_spain.5

	trigger = {
		NOT = { has_global_flag = spanish_civil_war }
	}

	is_triggered_only = yes

	hidden = yes

	immediate = {
		random_list = {
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						171 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					171 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					171 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_galicia_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					790 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					790 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					790 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_asturias_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						174 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					174 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					174 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_leon_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						791 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					791 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					791 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_valladolid_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						176 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					176 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					176 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_burgos_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					792 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					792 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					792 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_pais_vasco_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						172 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					172 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					172 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_navarra_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						166 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					166 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					166 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_western_aragon_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					794 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					794 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					794 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_eastern_aragon_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					165 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					165 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					165 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_catalunya_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						788 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						is_historical_focus_on = yes
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					788 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					NOT = { has_country_flag = SPA_secure_the_northern_garrisons_flag }
				}
				modifier = {
					factor = 10
					788 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_salamanca_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					41 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					41 = { check_variable = { var = SPA_garrison_control value = 2 compare = greater_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					41 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					41 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				activate_mission = SPA_expand_influence_in_the_madrid_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					793 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					793 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					793 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_guadalajara_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					167 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					167 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					167 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_valencia_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						170 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						AND = {
							is_historical_focus_on = yes
							170 = { check_variable = { var = SPA_garrison_control value = 4 compare = less_than } }
						}
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
					is_ai = yes
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					170 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					170 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_extremadura_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					175 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					175 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					175 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_ciudad_real_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					168 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					168 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					168 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_murcia_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						169 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						AND = {
							is_historical_focus_on = yes
							169 = { check_variable = { var = SPA_garrison_control value = 4 compare = less_than } }
						}
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
					is_ai = yes
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					169 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					169 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_sevilla_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					OR = {
						789 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
						AND = {
							is_historical_focus_on = yes
							789 = { check_variable = { var = SPA_garrison_control value = 3 compare = less_than } }
						}
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
					is_ai = yes
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					789 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					789 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 20
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_cordoba_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					173 = { check_variable = { var = SPA_garrison_control value = 2 compare = less_than } }
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					173 = { check_variable = { var = SPA_garrison_control value = 4 compare = equals } }
				}
				modifier = {
					factor = 10
					173 = { has_state_flag = SPR_ai_recently_expanded_influence_flag }
				}
				modifier = {
					factor = 10
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
				}
				activate_mission = SPA_expand_influence_in_the_granada_garrison_mission
			}
			20 = {
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = no
					any_owned_state = {
						check_variable = { var = SPA_garrison_control value = 2 compare = greater_than_or_equals }
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPA_a_great_spain
					is_historical_focus_on = yes
					OR = {
						any_owned_state = {
							NOT = { state = 166 }
							NOT = { state = 169 }
							NOT = { state = 170 }
							NOT = { state = 171 }
							NOT = { state = 172 }
							NOT = { state = 174 }
							NOT = { state = 176 }
							NOT = { state = 788 }
							NOT = { state = 789 }
							NOT = { state = 791 }
							check_variable = { var = SPA_garrison_control value = 2 compare = greater_than_or_equals }
						}
						any_owned_state = {
							OR = {
								state = 169
								state = 170
							}
							check_variable = { var = SPA_garrison_control value = 4 compare = equals }
						}
						789 = {
							check_variable = { var = SPA_garrison_control value = 3 compare = greater_than_or_equals }
						}
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = no
					any_owned_state = {
						check_variable = { var = SPA_garrison_control value = 4 compare = less_than }
					}
				}
				modifier = {
					factor = 0
					has_completed_focus = SPR_the_popular_front
					is_historical_focus_on = yes
					any_owned_state = {
						OR = {
							state = 166
							state = 169
							state = 170
							state = 171
							state = 172
							state = 174
							state = 176
							state = 788
							state = 789
							state = 791
						}
						check_variable = { var = SPA_garrison_control value = 4 compare = less_than }
					}
				}
				modifier = { # Preventing potential error log and logic breaking due to all options in the random list returning 0.
					add = 0.01
					always = yes
				}
				country_event = { id = lar_spain.5 days = 1 random_days = 9 }
			}
		}
	}
}

# Spanish Civil War - Frontlines Solidify
country_event = {
	id = lar_spain.6
	title = lar_spain.6.t
	desc = lar_spain.6.desc
	picture = GFX_report_event_spr_spanish_civil_war2
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			set_global_flag = scw_frontlines_solidify
			remove_ideas = SPA_planned_uprising
			every_state = {
				limit = {
					OR = {
						state = 41
						state = 165
						state = 166
						state = 167
						state = 168
						state = 169
						state = 170
						state = 171
						state = 172
						state = 173
						state = 174
						state = 175
						state = 176
						state = 788
						state = 789
						state = 790
						state = 791
						state = 792
						state = 793
						state = 794
					}
				}
				set_state_flag = SPR_unplanned_offensive_flag
				add_dynamic_modifier = {
					modifier = unplanned_offensive
				}
			}
		}
	}
	
	option = {
		name = lar_spain.6.a
		if = {
			limit = {
				tag = SPA
			}
			effect_tooltip = { remove_ideas = SPA_planned_uprising }
		}
		effect_tooltip = {
			every_state = {
				limit = {
					OR = {
						state = 41
						state = 165
						state = 166
						state = 167
						state = 168
						state = 169
						state = 170
						state = 171
						state = 172
						state = 173
						state = 174
						state = 175
						state = 176
						state = 788
						state = 789
						state = 790
						state = 791
						state = 792
						state = 793
						state = 794
					}
				}
				add_dynamic_modifier = {
					modifier = unplanned_offensive
				}
			}
		}
		custom_effect_tooltip = lar_spain.6_tt
	}
}

# Spanish Civil War - Carlists rise up
country_event = {
	id = lar_spain.7
	title = lar_spain.7.t
	desc = {
		text = lar_spain.7.desc
		trigger = {
			NOT = { has_global_flag = scw_early_end }
		}
	}
	desc = {
		text = lar_spain.7.desc_2
		trigger = {
			has_global_flag = scw_early_end
		}
	}
	picture = GFX_report_event_spr_carlists
	
	fire_only_once = yes

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			SPB = {
				set_politics = {
					ruling_party = neutrality
				}
				set_popularities = {
					democratic = 13
					neutrality = 82
					fascism = 5
				}
				set_party_name = { ideology = neutrality long_name = SPR_neutrality_party_long name = SPR_neutrality_party }
			}
			if = { # If SPA owns both of the historical Carlist states
				limit = {
					controls_state = 172
					controls_state = 176
				}
				every_state = {
					limit = {
						OR = {
							state = 172
							state = 176
						}
						is_controlled_by = ROOT
					}
					SPB = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 10
						controls_state = 791
					}
					SPB = {
						transfer_state = 791
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 11
						controls_state = 174
					}
					SPB = {
						transfer_state = 174
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 13
						controls_state = 171
					}
					SPB = {
						transfer_state = 171
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 14
						has_global_flag = scw_early_end
					}
					random_owned_state = {
						limit = {
							any_neighbor_state = {
								OR = {
									state = 171
									state = 172
									state = 174
									state = 176
									state = 791
								}
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
					random_owned_state = {
						limit = {
							any_neighbor_state = {
								OR = {
									state = 171
									state = 172
									state = 174
									state = 176
									state = 791
								}
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
				}
			}
			else_if = { # Fallback if not owning one of the historically Carlist states
				limit = {
					OR = {
						AND = {
							controls_state = 172
							NOT = { controls_state = 176 }
						}
						AND = {
							controls_state = 176
							NOT = { controls_state = 172 }
						}
					}
				}
				every_state = {
					limit = {
						OR = {
							state = 172
							state = 176
						}
						is_controlled_by = ROOT
					}
					SPB = {
						transfer_state = PREV
					}
				}
			}
			else_if = { # Fallback if not owning one of the historically Carlist states
				limit = {
					OR = {
						AND = {
							controls_state = 172
							NOT = { controls_state = 176 }
						}
						AND = {
							controls_state = 176
							NOT = { controls_state = 172 }
						}
					}
				}
				every_state = {
					limit = {
						OR = {
							state = 172
							state = 176
						}
						is_controlled_by = ROOT
					}
					SPB = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 5
						OR = {
							controls_state = 171
							controls_state = 174
							controls_state = 791
						}
					}
					random_state = {
						limit = {
							OR = {
								state = 171
								state = 174
								state = 791
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
				}
				else = {
					random_state = {
						limit = {
							NOT = { state = 178 }
							NOT = { state = 177 }
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
				}
			}
			else_if = { # You're not getting out of a civil war by voluntarily giving up the targetable locations, pal!
				limit = {
					NOT = {
						controls_state = 172
						controls_state = 176
					}
					OR = {
						controls_state = 171
						controls_state = 174
						controls_state = 791
					}
				}
				random_state = {
					limit = {
						OR = {
							state = 171
							state = 174
							state = 791
						}
						has_state_flag = SPR_core_of_spain_flag
						is_controlled_by = ROOT
						is_capital = no
					}
					SPB = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 5
						OR = {
							controls_state = 171
							controls_state = 174
							controls_state = 791
						}
					}
					random_state = {
						limit = {
							OR = {
								state = 171
								state = 174
								state = 791
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
				}
				else = {
					random_state = {
						limit = {
							NOT = { state = 178 }
							NOT = { state = 177 }
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
				}
			}
			else_if = { # You're not getting out of a civil war by voluntarily giving up the targetable locations, pal!
				limit = {
					NOT = {
						controls_state = 172
						controls_state = 176
						controls_state = 171
						controls_state = 174
						controls_state = 791
					}
				}
				random_state = {
					limit = {
						NOT = { state = 178 }
						NOT = { state = 177 }
						has_state_flag = SPR_core_of_spain_flag
						is_controlled_by = ROOT
						is_capital = no
					}
					SPB = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 5
					}
					random_state = {
						limit = {
							NOT = { state = 178 }
							NOT = { state = 177 }
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPB = {
							transfer_state = PREV
						}
					}
				}
			}
			else = {
				random_state = {
					limit = {
						has_state_flag = SPR_core_of_spain_flag
						is_controlled_by = ROOT
						is_capital = no
					}
					SPB = {
						transfer_state = PREV
					}
				}
			}
			SPB = {
				random_owned_state = {
					limit = {
						is_controlled_by = SPB
						is_core_of = SPB
						NOT = {
							state = 177
							state = 178
						}
					}
					SPB = { set_capital = { state = PREV } }
				}
				inherit_technology = SPA
				set_stability = 0.6
				set_war_support = 0.5
				division_template = {
					name = "Requeté Carlista"
					template_counter = 8
					priority = 1
					division_names_group = SPR_INF_03
					is_locked = yes
					regiments = {
						infantry = { x = 0 y = 0 }
						infantry = { x = 0 y = 1 }
						infantry = { x = 0 y = 2 }
					}
				}
				set_division_template_lock = {
				    division_template = "Requeté Carlista"
				    is_locked = no
				}
				every_owned_state = {
					create_unit = {
						division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
						owner = SPB
					}
					create_unit = {
						division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
						owner = SPB
					}
					create_unit = {
						division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
						owner = SPB
					}
					create_unit = {
						division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
						owner = SPB
					}
				}
				if = {
					limit = {
						NOT = {
							owns_state = 791
							owns_state = 174
							owns_state = 171
						}
					}
					every_owned_state = {
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
							owner = SPB
						}
						create_unit = {
							division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
							owner = SPB
						}
					}
				}
				if = {
					limit = {
						owns_state = 172
					}
					set_capital = { state = 172 }
				}
				else = {
					random_owned_state = {
						SPB = {
							set_capital = { state = PREV }
						}
					}
				}
			}
			add_popularity = {
			    ideology = neutrality
			    popularity = -0.15
			}
			add_stability = -0.1
			delete_unit_template_and_units = {
				division_template = "Requeté Carlista"
			}
			transfer_units_fraction = {
				target = SPB
				stockpile_ratio = 0.2
				army_ratio = 0.1
				navy_ratio = 0.1
				air_ratio = 0.1
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					has_trait = trait_SPA_falangist_loyalties
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_carlist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_carlist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPB
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_falangist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_falangist_loyalties
			}
			set_global_flag = SPR_carlist_uprising_flag
			set_global_flag = { flag = SPR_civil_war_startup value = 1 days = 3 } # Make AI avoid attacking for a few days
			SPB = {
				every_unit_leader = {
					limit = {
						has_trait = trait_SPA_nationalist_sympathies
					}
					remove_unit_leader_trait = trait_SPA_nationalist_sympathies
				}
				declare_war_on = {
				    target = ROOT
				    type = civil_war
				}
				add_civil_war_target = ROOT
				add_ai_strategy = {
					type = antagonize
					id = SPA
					value = 200
				}
				declare_war_on = {
				    target = SPD
				    type = civil_war
				}
				add_civil_war_target = SPD

				add_ai_strategy = {
					type = antagonize
					id = SPD
					value = 200
				}
				if = {
					limit = {
						country_exists = SPC
					}
					declare_war_on = {
					    target = SPC
					    type = civil_war
					}
					add_civil_war_target = SPC

					add_ai_strategy = {
						type = antagonize
						id = SPC
						value = 200
					}
				}
			}
			every_other_country = {
				add_ai_strategy = {
					type = support
					id = SPB
					value = -200
				}
				add_ai_strategy = {
					type = protect
					id = SPB
					value = -200
				}
				add_ai_strategy = {
					type = befriend
					id = SPB
					value = -200
				}
				add_ai_strategy = {
					type = alliance
					id = SPB
					value = -200
				}
			}
			SPB = {
				load_focus_tree = {
					tree = spanish_focus
					keep_completed = no
				}
				unlock_national_focus = SPA_a_great_spain
				unlock_national_focus = SPA_hand_over_the_ceda_campaign_chest
				unlock_national_focus = SPA_negotiate_carlist_support
				unlock_national_focus = SPA_the_army_of_africa
				unlock_national_focus = SPA_secure_the_northern_garrisons
				if = {
					limit = {
						SPA = { has_completed_focus = SPA_sin_paquito }
					}
					unlock_national_focus = SPA_sin_paquito
				}
				if = {
					limit = {
						SPA = { has_completed_focus = SPA_con_paquito }
					}
					unlock_national_focus = SPA_con_paquito
				}
				complete_national_focus = SPA_supremacy_of_the_communion
				complete_national_focus = SPA_prepare_the_carlist_insurrection
				complete_national_focus = SPA_contact_the_union_militar_espanola
				complete_national_focus = SPA_head_the_junta_nacional
				complete_national_focus = SPA_unite_the_requetes
				unlock_national_focus = SPA_no_compromise_on_carlist_ideals
				add_timed_idea = { idea = SPA_death_before_surrender days = 900 }
				every_unit_leader = {
					limit = {
						has_trait = trait_SPA_carlist_loyalties
					}
					remove_unit_leader_trait = trait_SPA_carlist_loyalties
				}
			}
			if = {
				limit = {
					has_idea = SPA_carlism_1
				}
				remove_ideas = SPA_carlism_1
			}
			if = {
				limit = {
					has_idea = SPA_carlism_2
				}
				remove_ideas = SPA_carlism_2
			}
			if = {
				limit = {
					has_idea = SPA_carlism_3
				}
				remove_ideas = SPA_carlism_3
			}
			if = {
				limit = {
					has_idea = SPA_carlism_4
				}
				remove_ideas = SPA_carlism_4
			}
			if = {
				limit = {
					has_idea = SPA_carlism_5
				}
				remove_ideas = SPA_carlism_5
			}

			## SPA triggers Carlist Uprising ##
			# If any country has already joined SCW, it will join the war against SPB as well
			if = { #Country supporting SPD
				limit = {
					any_country = { has_country_flag = supports_SPD_flag }
				}
				every_country = {
					limit = { has_country_flag = supports_SPD_flag }
					add_to_war = { targeted_alliance = SPD enemy = SPB hostility_reason = asked_to_join }
				}
				if = {
					limit = {
						any_country = { has_country_flag = POR_non_aligned_portugal_supports_SPA_flag }
					}
					random_country = { #Portuguese Non-aligned tag (spawned via Workers of Iberia, Unite! focus) will join war
						limit = {
							has_country_flag = POR_non_aligned_portugal_supports_SPA_flag
						}
						add_to_war = { targeted_alliance = SPA enemy = SPB hostility_reason = asked_to_join }
					}
				}
			}
			if = { #Country supporting SPA
				limit = {
					any_country = { has_country_flag = supports_SPA_flag }
				}
				every_country = {
					limit = { has_country_flag = supports_SPA_flag }
					add_to_war = { targeted_alliance = SPA enemy = SPB hostility_reason = asked_to_join }
				}
			}
			every_state = {
				limit = {
					has_state_flag = SPR_core_of_spain_flag
				}
				add_core_of = SPB
			}
			news_event = { id = lar_news.10 days = 1 }
		}
	}
	
	option = {
		name = lar_spain.7.a
		effect_tooltip = {
			add_popularity = {
			    ideology = neutrality
			    popularity = -0.15
			}
			add_stability = -0.1
			delete_unit_template_and_units = {
				division_template = "Requeté Carlista"
			}
			transfer_units_fraction = {
				target = SPB
				stockpile_ratio = 0.2
				army_ratio = 0.1
				navy_ratio = 0.1
				air_ratio = 0.1
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					has_trait = trait_SPA_falangist_loyalties
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_carlist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_carlist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPB
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_falangist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_falangist_loyalties
			}
			SPB = {
				declare_war_on = {
				    target = ROOT
				    type = civil_war
				}
				add_civil_war_target = ROOT
				declare_war_on = {
				    target = SPD
				    type = civil_war
				}
				add_civil_war_target = SPD
				if = {
					limit = {
						country_exists = SPC
					}
					declare_war_on = {
					    target = SPC
					    type = civil_war
					}
					add_civil_war_target = SPC
				}
			}
		}
	}
}

# Spanish Civil War - Fascist Anti-Carlist Crack-down
country_event = {
	id = lar_spain.8
	title = lar_spain.8.t
	desc = {
		text = lar_spain.8.desc
		trigger = {
			NOT = { has_global_flag = scw_early_end }
		}
	}
	desc = {
		text = lar_spain.8.desc_2
		trigger = {
			has_global_flag = scw_early_end
		}
	}
	picture = GFX_report_event_spr_nationalist_soldiers
	
	fire_only_once = yes

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			every_other_country = {
				limit = {
					ROOT = {
						has_volunteers_amount_from = {
						    tag = PREV
						    count > 0
						}
					}
				}
				recall_volunteers_from = ROOT
			}
			set_global_flag = SPR_carlist_uprising_flag
			set_global_flag = { flag = SPR_civil_war_startup value = 1 days = 3 } # Make AI avoid attacking for a few days
			if = {
				limit = {
					NOT = { has_government = neutrality }
				}
				set_politics = {
					ruling_party = neutrality
				}
			}
			SPB = {
				clr_country_flag = SPR_carlist_spain_flag
				drop_cosmetic_tag = yes
				set_country_flag = SPR_nationalist_spain_flag
				if = {
					limit = {
						has_game_rule = {
							rule = spr_fragmentation_status
							option = SPR_EU4
						}
					}
					set_cosmetic_tag = SPR_nationalist_castille
				}
				else = {
					set_cosmetic_tag = SPR_nationalist_spain
				}
			}
			clr_country_flag = SPR_nationalist_spain_flag
			drop_cosmetic_tag = yes
			set_country_flag = SPR_carlist_spain_flag
			if = {
				limit = {
					has_game_rule = {
						rule = spr_fragmentation_status
						option = SPR_EU4
					}
				}
				set_cosmetic_tag = SPR_carlist_castille
			}
			else = {
				set_cosmetic_tag = SPR_carlist_spain
			}
			if = {
				limit = {
					any_state = {
						is_controlled_by = ROOT
						has_state_flag = SPA_carlist_cell_flag
					}
				}
				every_state = {
					limit = {
						NOT = { has_state_flag = SPA_carlist_cell_flag }
						is_controlled_by = ROOT
					}
					SPA = {
						transfer_state = PREV
					}
				}
			}
			else_if = {
				limit = {
					OR = {
						controls_state = 172
						controls_state = 176
					}
				}
				every_state = {
					limit = {
						NOT = { state = 172 }
						NOT = { state = 176 }
						NOT = { has_state_flag = SPA_carlist_cell_flag }
						is_controlled_by = ROOT
					}
					SPA = {
						transfer_state = PREV
					}
				}
			}
			else = {
				random_owned_state = {
					limit = {
						is_controlled_by = ROOT
					}
					set_state_flag = SPA_carlist_cell_flag
				}
				random_owned_state = {
					limit = {
						is_controlled_by = ROOT
						NOT = { has_state_flag = SPA_carlist_cell_flag }
					}
					set_state_flag = SPA_carlist_cell_flag
				}
				every_state = {
					limit = {
						NOT = { has_state_flag = SPA_carlist_cell_flag }
						is_controlled_by = ROOT
					}
					SPA = {
						transfer_state = PREV
					}
				}
			}
			SPA = {
				inherit_technology = SPB
				set_politics = {
					ruling_party = fascism
					last_election = "1933.4.26"
					election_frequency = 48
					elections_allowed = no
				}
				set_popularities = {
					fascism = 80
					democratic = 15
					neutrality = 5
				}
				set_stability = 0.6
				set_war_support = 0.5
				if = {
					limit = {
						owns_state = 172
					}
					set_capital = { state = 172 }
				}
				else = {
					random_owned_state = {
						limit = {
							is_controlled_by = SPA
							is_core_of = SPA
							NOT = {
								state = 177
								state = 178
							}
						}
						SPA = {
							set_capital = { state = PREV }
						}
					}
				}
				delete_unit_template_and_units = {
					division_template = "Requeté Carlista"
				}
				set_party_name = { ideology = neutrality long_name = SPR_neutrality_military_junta_party_long name = SPR_neutrality_military_junta_party }
			}
			set_party_name = { ideology = neutrality long_name = SPR_neutrality_party_long name = SPR_neutrality_party }
			add_popularity = {
			    ideology = fascism
			    popularity = -0.35
			}
			add_stability = -0.1
			transfer_units_fraction = {
				target = SPA
				stockpile_ratio = 0.4
				army_ratio = 0.3
				navy_ratio = 0.3
				air_ratio = 0.3
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					has_trait = trait_SPA_carlist_loyalties
				}
			}
			set_division_template_lock = {
			    division_template = "Requeté Carlista"
			    is_locked = no
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_falangist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_falangist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPA
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_carlist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_carlist_loyalties
			}
			SPA = {
				every_unit_leader = {
					limit = {
						has_trait = trait_SPA_falangist_loyalties
					}
					remove_unit_leader_trait = trait_SPA_falangist_loyalties
				}
				every_unit_leader = {
					limit = {
						has_trait = trait_SPA_nationalist_sympathies
					}
					remove_unit_leader_trait = trait_SPA_nationalist_sympathies
				}
				declare_war_on = {
				    target = ROOT
				    type = civil_war
				}
				add_civil_war_target = ROOT
				add_ai_strategy = {
					type = antagonize
					id = SPB
					value = 200
				}
				declare_war_on = {
				    target = SPD
				    type = civil_war
				}
				add_civil_war_target = SPD

				add_ai_strategy = {
					type = antagonize
					id = SPD
					value = 200
				}
				if = {
					limit = {
						country_exists = SPC
					}
					declare_war_on = {
					    target = SPC
					    type = civil_war
					}
					add_civil_war_target = SPC

					add_ai_strategy = {
						type = antagonize
						id = SPC
						value = 200
					}
				}
			}
			every_other_country = {
				add_ai_strategy = {
					type = support
					id = SPB
					value = -200
				}
				add_ai_strategy = {
					type = protect
					id = SPB
					value = -200
				}
				add_ai_strategy = {
					type = befriend
					id = SPB
					value = -200
				}
				add_ai_strategy = {
					type = alliance
					id = SPB
					value = -200
				}
			}
			SPA = {
				load_focus_tree = {
					tree = spanish_focus
					keep_completed = no
				}
				unlock_national_focus = SPA_a_great_spain
				unlock_national_focus = SPA_hand_over_the_ceda_campaign_chest
				unlock_national_focus = SPA_negotiate_carlist_support
				unlock_national_focus = SPA_the_army_of_africa
				unlock_national_focus = SPA_secure_the_northern_garrisons
				unlock_national_focus = SPA_sin_paquito
				complete_national_focus = SPA_the_phalanx_ascendant
				complete_national_focus = SPA_secure_the_national_defense_council
				complete_national_focus = SPA_suspend_the_constitution
				unlock_national_focus = SPA_eliminate_the_carlists
				complete_national_focus = SPA_primo_de_rivera_prisoner_exchange
				complete_national_focus = SPA_establish_the_directory
				add_timed_idea = { idea = SPA_death_before_surrender days = 900 }
			}

			## SPB triggers Carlist Uprising ##
			### All foreign Aid goes to SPA ###
			#Portuguese Op. modifier goes to SPA
			if = {
				limit = {
					has_opinion_modifier = POR_helped_in_civil_war
				}
				remove_opinion_modifier = {
					target = POR
					modifier = POR_helped_in_civil_war
				}
				SPA = {
					add_opinion_modifier = {
					    target = POR
					    modifier = POR_helped_in_civil_war
					}
				}
			}
			if = {#Country supporting SPA
				limit = { 
					any_country = { has_country_flag = supports_SPA_flag }
				}
				every_country = {
					limit = {
						 has_country_flag = supports_SPA_flag
					}
					diplomatic_relation = {
						country = SPA
						relation = military_access
						active = yes
					}
					SPA = {
						diplomatic_relation = {
							country = PREV
							relation = military_access
							active = yes
						}
					}
					#Join war against all SPA enemies
					every_country = {
						limit = { has_war_with = SPA }
						PREV = {
							add_to_war = {
								targeted_alliance = SPA
								enemy = PREV
								hostility_reason = asked_to_join
							}
						}
					}
				}
			
				#Transfer troops in territory belonging to SPA allies back home
				every_state = {
					limit = {
						NOT = { is_fully_controlled_by = ROOT }
						owner = {
							has_war_together_with = SPA
						}
					}
					teleport_armies = {
						limit = { 
							tag = SPB
						}
						to_state_array = owned_controlled_states
					}
				}
			}
			if = {	#Country supporting SPD
				limit = {
					any_country = { has_country_flag = supports_SPD_flag }
				}
				every_country = {
					limit = {
						has_country_flag = supports_SPD_flag
					}
					# Country joins war against SPA
					add_to_war = { targeted_alliance = SPD enemy = SPA hostility_reason = asked_to_join }
				}
				if = {
					limit = {
						any_country = { has_country_flag = POR_non_aligned_portugal_supports_SPA_flag }
					}
					random_country = { #Portuguese Non-aligned tag (spawned via Workers of Iberia, Unite! focus) will join war
						limit = {
							has_country_flag = POR_non_aligned_portugal_supports_SPA_flag
						}
						add_to_war = { targeted_alliance = SPA enemy = SPB hostility_reason = asked_to_join }
					}
				}
			}
			every_state = {
				limit = {
					has_state_flag = SPR_core_of_spain_flag
				}
				add_core_of = SPB
				add_core_of = SPA
			}
			news_event = { id = lar_news.10 days = 1 }
		}
	}
	
	option = {
		name = lar_spain.8.a
		effect_tooltip = {
			if = {
				limit = {
					NOT = { has_government = neutrality }
				}
				set_politics = {
					ruling_party = neutrality
				}
			}
			add_popularity = {
			    ideology = fascism
			    popularity = -0.35
			}
			add_stability = -0.1
			transfer_units_fraction = {
				target = SPA
				stockpile_ratio = 0.4
				army_ratio = 0.3
				navy_ratio = 0.3
				air_ratio = 0.3
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					has_trait = trait_SPA_carlist_loyalties
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_falangist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_falangist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPA
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPA_carlist_loyalties
				}
				remove_unit_leader_trait = trait_SPA_carlist_loyalties
			}
			set_division_template_lock = {
			    division_template = "Requeté Carlista"
			    is_locked = no
			}
			SPA = {
				declare_war_on = {
				    target = ROOT
				    type = civil_war
				}
				add_civil_war_target = ROOT
				declare_war_on = {
				    target = SPD
				    type = civil_war
				}
				add_civil_war_target = SPD
				if = {
					limit = {
						country_exists = SPC
					}
					declare_war_on = {
					    target = SPC
					    type = civil_war
					}
					add_civil_war_target = SPC
				}
			}
		}
		random_state = {
			limit = {
				has_state_flag = SPA_union_militar_flag
			}
			create_unit = {
				division = "division_template = \"Requeté Carlista\" start_experience_factor = 0.3" 
				owner = SPB
				allow_spawning_on_enemy_provs = yes
				count = 5
			}
		}
	}
}

# Spanish Civil War - Anarchists rise up ("player" goes SPD)
country_event = {
	id = lar_spain.9
	title = lar_spain.9.t
	desc = {
		text = lar_spain.9.desc
		trigger = {
			NOT = { has_global_flag = scw_early_end }
		}
	}
	desc = {
		text = lar_spain.9.desc_2
		trigger = {
			has_global_flag = scw_early_end
		}
	}
	picture = GFX_report_event_spr_anarchist_uprising2
	
	fire_only_once = yes
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			set_global_flag = SPR_anarchist_uprising_flag
			set_global_flag = { flag = SPR_civil_war_startup value = 1 days = 3 } # Make AI avoid attacking for a few days
			if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
				limit = {
					has_global_flag = SOV_covert_support_for_poum_flag
				}
				if = {
					limit = {
						communism > 0.03
					}
					set_political_party = {
					    ideology = communism
					    popularity = 3
					}
				}
				add_popularity = {
				    ideology = neutrality
				    popularity = -0.05
				}
				SPC = {
					set_rule = {
						can_generate_female_aces = yes
					}
					set_politics = {
						ruling_party = communism
					}
					set_popularities = {
						communism = 58
						democratic = 2
						neutrality = 40
					}
					create_country_leader = {
						name = "Julián Gorkin"
						desc = "POLITICS_JULIAN_GORKIN_DESC"
						picture = "GFX_portrait_SPR_julian_gorkin"
						expire = "1965.1.1"
						ideology = anarchist_communism
						traits = {
							militant_socialist
						}
					}
					#Check for covert depots from Soviets
					if = {
						limit = {
							has_global_flag = SOV_poum_has_covert_depots_from_soviets_flag
						}
						add_equipment_to_stockpile = {
							type = infantry_equipment
							amount = 6000
							producer = SOV
						}
						add_equipment_to_stockpile = {
							type = support_equipment
							amount = 600
							producer = SOV
						}
						add_equipment_to_stockpile = {
							type = artillery_equipment
							amount = 120
							producer = SOV
						}
						add_equipment_to_stockpile = {
							type = motorized_equipment
							amount = 60
							producer = SOV
						}
						add_equipment_to_stockpile = {
							type = train_equipment
							amount = 6
							producer = SOV
						}
						add_opinion_modifier = {
							target = SOV
							modifier = SOV_sent_us_weapons
						}
					}
				}
				if = { #If Right Opposition is still under Stalin's rule, volunteers come back
					limit = {
						SOV = { has_completed_focus = SOV_covert_support_for_spanish_poum }
						SPD = {
							has_volunteers_amount_from = {
								tag = SOV
								count > 0
							}
						}
					}
					SOV = {	recall_volunteers_from = SPD }
				}
			}
			else = { #REGULAR ANARCHIST UPRISING
				if = {
					limit = {
						neutrality > 0.03
					}
					set_political_party = {
					    ideology = neutrality
					    popularity = 3
					}
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.05
				}
				SPC = {
					set_rule = {
					    can_puppet = no
					    can_create_factions = no
					    can_join_factions = no
					    can_boost_own_ideology = no
						can_generate_female_aces = yes
						can_create_collaboration_government = no
					}
					set_politics = {
						ruling_party = neutrality
					}
					set_popularities = {
						communism = 40
						democratic = 2
						neutrality = 58
					}
					create_country_leader = {
						name = "Anarchist Commune"
						desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
						picture = "GFX_portrait_SPR_anarchist_commune"
						expire = "1965.1.1"
						ideology = anarchism
						traits = {
							our_right_to_survive
						}
					}
				}
			}
			if = {
				limit = {
					165 = {
						is_capital = yes
					}
				}
				random_owned_controlled_state = {
					limit = {
						NOT = {
							state = 165
						}
					}
					ROOT = {
						set_capital = {
							state = PREV
						}
					}
				}

			}

			if = {
				limit = {
					OR = {
						controls_state = 165
						controls_state = 794
						controls_state = 166
					}
				}
				every_state = {
					limit = {
						OR = {
							state = 165
							state = 794
							state = 166
						}
						is_capital = no
						is_controlled_by = ROOT
					}
					SPC = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						SPC = {
							NOT = {
								AND = {
									controls_state = 165
									controls_state = 794
									controls_state = 166
								}
							}
						}
						num_of_controlled_states > 8
					}
					random_state = {
						limit = {
							NOT = { state = 178 }
							NOT = { state = 177 }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									state = 166
								}
								is_owned_by = SPC
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPC = {
							transfer_state = PREV
						}
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 15
						has_global_flag = scw_early_end
					}
					SPC = {
						transfer_state = 167
					}
					random_owned_state = {
						limit = {
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									state = 166
									state = 167
								}
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPC = {
							transfer_state = PREV
						}
					}
					random_owned_state = {
						limit = {
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									state = 166
									state = 167
								}
							}
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPC = {
							transfer_state = PREV
						}
					}
				}
			}
			else = { # You're not getting out of a civil war by voluntarily giving up the targetable locations, pal!
				random_state = {
					limit = {
						NOT = { state = 178 }
						NOT = { state = 177 }
						has_state_flag = SPR_core_of_spain_flag
						is_controlled_by = ROOT
						is_capital = no
					}
					SPC = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 3
					}
					random_state = {
						limit = {
							NOT = { state = 178 }
							NOT = { state = 177 }
							has_state_flag = SPR_core_of_spain_flag
							is_controlled_by = ROOT
							is_capital = no
						}
						SPC = {
							transfer_state = PREV
						}
					}
				}
			}
			if = {
				limit = {
					SPC = {
						owns_state = 165
					}
				}
				SPC = { set_capital = { state = 165 } }
			}
			else = {
				SPC = {
					random_owned_state = {
						limit = {
							is_controlled_by = SPC
							is_core_of = SPC
							NOT = {
								state = 177
								state = 178
							}
						}
						SPC = { set_capital = { state = PREV } }
					}
				}
			}
			SPC = {
				inherit_technology = SPD

				if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
					limit = {
						has_global_flag = SOV_covert_support_for_poum_flag
					}
					set_politics = {
						ruling_party = communism
						last_election = "1933.4.26"
						election_frequency = 48
						elections_allowed = no
					}
					set_popularities = {
						neutrality = 15
						communism = 80
						democratic = 5
					}

				}
				else = { #REGULAR ANARCHIST UPRISING
					set_politics = {
						ruling_party = neutrality
						last_election = "1933.4.26"
						election_frequency = 48
						elections_allowed = no
					}
					set_popularities = {
						neutrality = 80
						communism = 15
						democratic = 5
					}
				}
				
				remove_ideas = SPR_the_maximum_concession
				add_ideas = closed_economy
				set_stability = 0.6
				set_war_support = 0.5
				division_template = { #No matter if POUM or Anarchist split, what really matters is the triumph of the revolution during the SCW
					name = "Brigada Anarquista"
					template_counter = 0
					priority = 1
					division_names_group = SPD_INF_04
					is_locked = yes
					regiments = {
						infantry = { x = 0 y = 0 }
						infantry = { x = 0 y = 1 }
						infantry = { x = 0 y = 2 }
					}
				}
				every_owned_state = {
					create_unit = {
						division = "division_template = \"Brigada Anarquista\" start_experience_factor = 0 start_equipment_factor = 0.25" 
						owner = SPC
					}
					create_unit = {
						division = "division_template = \"Brigada Anarquista\" start_experience_factor = 0 start_equipment_factor = 0.25" 
						owner = SPC
					}
					create_unit = {
						division = "division_template = \"Brigada Anarquista\" start_experience_factor = 0 start_equipment_factor = 0.25" 
						owner = SPC
					}
				}
				if = {
					limit = {
						num_of_controlled_states < 3
					}
					every_owned_state = {
						create_unit = {
							division = "division_template = \"Brigada Anarquista\" start_experience_factor = 0 start_equipment_factor = 0.25" 
							owner = SPC
						}
						create_unit = {
							division = "division_template = \"Brigada Anarquista\" start_experience_factor = 0 start_equipment_factor = 0.25" 
							owner = SPC
						}
					}
				}
				if = {
					limit = {
						OR = {
							AND = {
								num_of_controlled_states > 2
								num_of_controlled_states < 4
							}
							has_global_flag = scw_early_end
						}
					}
					every_owned_state = {
						create_unit = {
							division = "division_template = \"Brigada Anarquista\" start_experience_factor = 0 start_equipment_factor = 0.25" 
							owner = SPC
						}
					}
				}
			}
			add_popularity = {
			    ideology = neutrality
			    popularity = -0.25
			}
			add_stability = -0.1
			transfer_units_fraction = {
				target = SPC
				stockpile_ratio = 0.2
				army_ratio = 0.1
				navy_ratio = 0.1
				air_ratio = 0.1
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					OR = {
						has_trait = trait_SPR_republican_loyalties
						has_trait = trait_SPR_stalinist_loyalties
					}
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_republican_loyalties
				}
				remove_unit_leader_trait = trait_SPR_republican_loyalties
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_stalinist_loyalties
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_anti_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPC
				}
			}
			SPC = {
				every_unit_leader = {
					limit = {
						has_trait = trait_SPR_anti_stalinist_loyalties
					}
					remove_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
				}
				declare_war_on = {
				    target = SPA
				    type = civil_war
				}
				add_civil_war_target = SPA

				add_ai_strategy = {
					type = antagonize
					id = SPA
					value = 200
				}
				declare_war_on = {
				    target = SPD
				    type = civil_war
				}
				add_civil_war_target = SPD

				add_ai_strategy = {
					type = antagonize
					id = SPD
					value = 200
				}
				if = {
					limit = {
						country_exists = SPB
					}
					declare_war_on = {
					    target = SPB
					    type = civil_war
					}
					add_civil_war_target = SPB

					add_ai_strategy = {
						type = antagonize
						id = SPB
						value = 200
					}
				}
			}
			if = {
				limit = {
					has_completed_focus = SPR_the_anti_fascist_workers_revolution
					NOT = {
						has_completed_focus = SPR_the_stalinist_doctrine
					}
				}
				complete_national_focus = SPR_the_stalinist_doctrine
			}
			SPC = {
				load_focus_tree = {
					tree = spanish_focus
					keep_completed = no
				}
				set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
				set_party_name = { ideology = communism long_name = SPR_communism_independent_party_long name = SPR_communism_independent_party }
				create_country_leader = {
					name = "Anarchist Commune"
					desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
					picture = "GFX_portrait_SPR_anarchist_commune"
					expire = "1965.1.1"
					ideology = anarchism
					traits = {
						our_right_to_survive
					}
				}
				unlock_national_focus = SPR_the_popular_front
				if = {
					limit = {
						SPD = { has_completed_focus = SPR_secure_the_guardia_civil }
					}
					unlock_national_focus = SPR_secure_the_guardia_civil
				}
				if = {
					limit = {
						SPD = { has_completed_focus = SPR_secure_the_guardia_de_asalto }
					}
					unlock_national_focus = SPR_secure_the_guardia_de_asalto
				}
				unlock_national_focus = SPR_train_the_union_youth
				unlock_national_focus = SPR_enlarge_the_weapon_caches
				unlock_national_focus = SPR_distribute_arms_to_the_people
				unlock_national_focus = SPR_disband_the_army
				if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
					limit = {
						has_global_flag = SOV_covert_support_for_poum_flag
					}
					complete_national_focus = SPR_the_anti_fascist_workers_revolution
					complete_national_focus = SPR_arm_the_workers_militias
					complete_national_focus = SPR_demand_ministerial_positions
					unlock_national_focus = SPR_hinder_nkvd_interference
				}
				else = { #REGULAR ANARCHIST UPRISING
					complete_national_focus = SPR_regional_defense_council_of_aragon
					complete_national_focus = SPR_arm_the_people
					complete_national_focus = SPR_appropriate_the_means_of_production
					unlock_national_focus = SPR_the_maximum_concession
				}
				unlock_national_focus = SPR_seize_the_gold_reserves
				unlock_national_focus = SPR_masters_of_our_own_fate
				add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
			}

			## SPD triggers Anarchist Uprising ##
			# If any country has already joined SCW, it will join the war against SPC as well
			if = { #Country supporting SPD
				limit = {
					any_country = { has_country_flag = supports_SPD_flag }
				}
				every_country = {
					limit = { has_country_flag = supports_SPD_flag }
					add_to_war = { targeted_alliance = SPD enemy = SPC hostility_reason = asked_to_join }
				}
				if = { #Portuguese Non-aligned tag (spawned via Workers of Iberia, Unite! focus) will join war
					limit = {
						any_country = { has_country_flag = POR_non_aligned_portugal_supports_SPA_flag }
					}
					random_country = {
						limit = {
							has_country_flag = POR_non_aligned_portugal_supports_SPA_flag
						}
						add_to_war = { targeted_alliance = SPA enemy = SPC hostility_reason = asked_to_join }
					}
				}
			}
			if = { #Country supporting SPA
				limit = {
					any_country = { has_country_flag = supports_SPA_flag }
				}
				every_country = {
					limit = { has_country_flag = supports_SPA_flag }
					add_to_war = { targeted_alliance = SPA enemy = SPC hostility_reason = asked_to_join }
				}
			}
			if = { #Country supporting SPB
				limit = {
					any_country = { has_country_flag = supports_SPB_flag }
				}
				every_country = {
					limit = { has_country_flag = supports_SPB_flag }
					add_to_war = { targeted_alliance = SPB enemy = SPC hostility_reason = asked_to_join }
				}
			}
			every_state = {
				limit = {
					has_state_flag = SPR_core_of_spain_flag
				}
				add_core_of = SPC
			}
			news_event = { id = lar_news.11 days = 1 }
		}
	}
	
	option = {
		name = lar_spain.9.a
		effect_tooltip = {
			if = { #POUM UPRISING (SUPPORTED BY SOVIET RIGHT OPPOSITION)
				limit = {
					has_global_flag = SOV_covert_support_for_poum_flag
				}
				if = {
					limit = {
						communism > 0.03
					}
					set_political_party = {
					    ideology = communism
					    popularity = 3
					}
				}
				add_popularity = {
				    ideology = neutrality
				    popularity = -0.05
				}
			}
			else = { #REGULAR ANARCHIST UPRISING
				if = {
					limit = {
						neutrality > 0.03
					}
					set_political_party = {
					    ideology = neutrality
					    popularity = 3
					}
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.05
				}
			}
			add_stability = -0.1
			transfer_units_fraction = {
				target = SPC
				stockpile_ratio = 0.2
				army_ratio = 0.1
				navy_ratio = 0.1
				air_ratio = 0.1
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					OR = {
						has_trait = trait_SPR_republican_loyalties
						has_trait = trait_SPR_stalinist_loyalties
					}
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_republican_loyalties
				}
				remove_unit_leader_trait = trait_SPR_republican_loyalties
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_stalinist_loyalties
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_anti_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPC
				}
			}
			SPC = {
				declare_war_on = {
				    target = SPA
				    type = civil_war
				}
				add_civil_war_target = SPA
				declare_war_on = {
				    target = SPD
				    type = civil_war
				}
				add_civil_war_target = SPD
				if = {
					limit = {
						country_exists = SPB
					}
					declare_war_on = {
					    target = SPB
					    type = civil_war
					}
					add_civil_war_target = SPB
				}
			}
		}
	}
}

# Spanish Civil War - Republican Crack-Down ("player" goes SPC)
country_event = {
	id = lar_spain.10
	title = lar_spain.10.t
	desc = {
		text = lar_spain.10.desc
		trigger = {
			NOT = { has_global_flag = scw_early_end }
		}
	}
	desc = {
		text = lar_spain.10.desc_2
		trigger = {
			has_global_flag = scw_early_end
		}
	}
	picture = GFX_report_event_spr_solidify_the_frontlines
	
	fire_only_once = yes
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			if = { #If POUM split + Right Oppo is in charge + tehy are supporting the POUM -> Then their volunteers stay in SPC
				limit = {
					has_completed_focus = SPR_the_anti_fascist_workers_revolution
					SOV = {
						has_completed_focus = SOV_covert_support_for_spanish_poum
						has_completed_focus = SOV_coup_detat
					}
				}
				every_other_country = { #Exclude SOV
					limit = {
						NOT = { tag = SOV }
						ROOT = {
							has_volunteers_amount_from = {
							    tag = PREV
							    count > 0
							}
						}
					}
					recall_volunteers_from = ROOT
				}
			}
			else = {
				every_other_country = { #Default
					limit = {
						ROOT = {
							has_volunteers_amount_from = {
							    tag = PREV
							    count > 0
							}
						}
					}
					recall_volunteers_from = ROOT
				}
			}
			
			set_global_flag = SPR_anarchist_uprising_flag
			set_global_flag = { flag = SPR_civil_war_startup value = 1 days = 3 } # Make AI avoid attacking for a few days
			if = {
				limit = {
					has_completed_focus = SPR_regional_defense_council_of_aragon
				}
				set_politics = {
					ruling_party = neutrality
				}
				set_party_name = { ideology = communism long_name = SPR_communism_independent_party_long name = SPR_communism_independent_party }
				create_country_leader = {
					name = "Julián Gorkin"
					desc = "POLITICS_JULIAN_GORKIN_DESC"
					picture = "GFX_portrait_SPR_julian_gorkin"
					expire = "1965.1.1"
					ideology = anarchist_communism
					traits = {
						militant_socialist
					}
				}
				create_country_leader = {
					name = "Anarchist Commune"
					desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
					picture = "GFX_portrait_SPR_anarchist_commune"
					expire = "1965.1.1"
					ideology = anarchism
					traits = {
						our_right_to_survive
					}
				}
				add_popularity = {
				    ideology = fascism
				    popularity = -1
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.25
				}
				if = {
					limit = {
						democratic > 0.01
					}
					set_political_party = {
					    ideology = democratic
					    popularity = 1
					}
				}
				set_rule = {
				    can_puppet = no
				    can_create_factions = no
				    can_join_factions = no
				    can_boost_own_ideology = no
					can_generate_female_aces = yes
					can_create_collaboration_government = no
				}
			}
			if = {
				limit = {
					has_completed_focus = SPR_the_anti_fascist_workers_revolution
				}
				set_politics = {
					ruling_party = communism
				}
				set_party_name = { ideology = communism long_name = SPR_communism_independent_party_long name = SPR_communism_independent_party }
				create_country_leader = {
					name = "Julián Gorkin"
					desc = "POLITICS_JULIAN_GORKIN_DESC"
					picture = "GFX_portrait_SPR_julian_gorkin"
					expire = "1965.1.1"
					ideology = anarchist_communism
					traits = {
						militant_socialist
					}
				}
				add_popularity = {
				    ideology = fascism
				    popularity = -1
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.05
				}
				if = {
					limit = {
						democratic > 0.01
					}
					set_political_party = {
					    ideology = democratic
					    popularity = 1
					}
				}
				#create_field_marshal = {
				#	name = "José Rovira"
				#	portrait_path = "gfx/leaders/Europe/Portrait_Europe_Generic_land_5.dds"
				#	traits = { infantry_officer politically_connected }
				#	skill = 3
				#    attack_skill = 2
				#    defense_skill = 2
				#    planning_skill = 2
				#    logistics_skill = 3
				#}
				add_field_marshal_role = { #TODO_Manu: All these guys should be handled with the new char system
					character = SPR_jose_rovira
					traits = { infantry_officer politically_connected }
					skill = 3
				    attack_skill = 2
				    defense_skill = 2
				    planning_skill = 2
				    logistics_skill = 3
				}
				create_corps_commander = {
					name = "Carmel Rosa Baserba"
					portrait_path = GFX_portrait_Carmel_Rosa_Baserba
					traits = { trait_cautious infantry_officer }
					skill = 3
				    attack_skill = 2
				    defense_skill = 2
				    planning_skill = 2
				    logistics_skill = 2
				}
				create_corps_commander = {
					name = "Luis Rastrollo"
					portrait_path = GFX_portrait_Luis_Rastrollo
					traits = { politically_connected }
					skill = 1
				    attack_skill = 1
				    defense_skill = 2
				    planning_skill = 1
				    logistics_skill = 1
				}
				set_rule = { can_generate_female_aces = yes	}

				#Check for covert depots from Soviets
				if = {
					limit = {
						has_global_flag = SOV_poum_has_covert_depots_from_soviets_flag
					}
					add_equipment_to_stockpile = {
						type = infantry_equipment
						amount = 6000
						producer = SOV
					}
					add_equipment_to_stockpile = {
						type = support_equipment
						amount = 600
						producer = SOV
					}
					add_equipment_to_stockpile = {
						type = artillery_equipment
						amount = 120
						producer = SOV
					}
					add_equipment_to_stockpile = {
						type = motorized_equipment
						amount = 60
						producer = SOV
					}
					add_equipment_to_stockpile = {
						type = train_equipment
						amount = 6
						producer = SOV
					}
					add_opinion_modifier = {
						target = SOV
						modifier = SOV_sent_us_weapons
					}
				}
			}
			remove_ideas = SPR_the_maximum_concession
			add_ideas = closed_economy
			SPC = {
				clr_country_flag = SPR_anarchist_spain_flag
				drop_cosmetic_tag = yes
				set_country_flag = SPR_republican_spain_flag
				if = {
					limit = {
						has_game_rule = {
							rule = spr_fragmentation_status
							option = SPR_EU4
						}
					}
					set_cosmetic_tag = SPR_republican_castille
				}
				else = {
					set_cosmetic_tag = SPR_republican_spain
				}
			}
			clr_country_flag = SPR_republican_spain_flag
			drop_cosmetic_tag = yes
			set_country_flag = SPR_anarchist_spain_flag
			if = {
				limit = {
					has_game_rule = {
						rule = spr_fragmentation_status
						option = SPR_EU4
					}
				}
				set_cosmetic_tag = SPR_anarchist_castille
			}
			else = {
				set_cosmetic_tag = SPR_anarchist_spain
			}
			if = {
				limit = {
					controls_state = 165
					controls_state = 794
				}
				set_capital = { state = 165 }
				every_state = {
					limit = {
						OR = {
							state = 165
							state = 794
							state = 166
						}
						is_controlled_by = ROOT
					}
					set_state_flag = SPR_anarchist_state_flag
				}
				if = {
					limit = {
						num_of_controlled_states > 7
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							NOT = { state = 41 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 9
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							NOT = { state = 41 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 11
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							NOT = { state = 41 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 13
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							NOT = { state = 41 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 15
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 17
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				if = {
					limit = {
						num_of_controlled_states > 19
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
					random_state = {
						limit = {
							NOT = { state = 165 }
							NOT = { state = 794 }
							NOT = { state = 166 }
							is_controlled_by = ROOT
							NOT = { has_state_flag = SPR_anarchist_state_flag }
							any_neighbor_state = {
								OR = {
									state = 165
									state = 794
									has_state_flag = SPR_anarchist_state_flag
								}
							}
						}
						set_state_flag = SPR_anarchist_state_flag
					}
				}
				every_state = {
					limit = {
						is_controlled_by = ROOT
						NOT = { has_state_flag = SPR_anarchist_state_flag }
					}
					SPD = {
						transfer_state = PREV
					}
				}
			}
			else_if = {
				limit = {
					OR = {
						controls_state = 165
						controls_state = 166
						controls_state = 794
					}
				}
				random_owned_state = {
					limit = {
						NOT = { state = 165 }
						NOT = { state = 794 }
						NOT = { state = 166 }
						is_controlled_by = ROOT
					}
					set_state_flag = SPR_anarchist_state_flag
				}
				every_state = {
					limit = {
						has_state_flag = SPR_core_of_spain_flag
						NOT = { state = 165 }
						NOT = { state = 794 }
						NOT = { state = 166 }
						is_controlled_by = ROOT
						NOT = { has_state_flag = SPR_anarchist_state_flag }
					}
					SPD = {
						transfer_state = PREV
					}
				}
				if = {
					limit = {
						owns_state = 165
					}
					set_capital = { state = 165 }
				}
				if = {
					limit = {
						NOT = { owns_state = 165 }
					}
					random_owned_state = {
						limit = {
							is_controlled_by = ROOT
							is_core_of = ROOT
							NOT = {
								state = 177
								state = 178
							}
						}
						ROOT = { set_capital = { state = PREV } }
					}
				}
			}
			else = {
				random_owned_state = {
					limit = {
						is_controlled_by = ROOT
					}
					set_state_flag = SPR_anarchist_state_flag
				}
				random_owned_state = {
					limit = {
						is_controlled_by = ROOT
						NOT = { has_state_flag = SPR_anarchist_state_flag }
					}
					set_state_flag = SPR_anarchist_state_flag
				}
				random_owned_state = {
					limit = {
						is_controlled_by = ROOT
						NOT = { has_state_flag = SPR_anarchist_state_flag }
					}
					set_state_flag = SPR_anarchist_state_flag
				}
				every_state = {
					limit = {
						is_controlled_by = ROOT
						NOT = { has_state_flag = SPR_anarchist_state_flag }
					}
					SPD = {
						transfer_state = PREV
					}
				}
				random_owned_state = {
					limit = {
						is_controlled_by = ROOT
					}
					ROOT = { set_capital = { state = PREV } }
				}
			}
			SPD = {
				inherit_technology = SPC
				set_politics = {
					ruling_party = democratic
					last_election = "1933.4.26"
					election_frequency = 48
					elections_allowed = yes
				}
				set_popularities = {
					democratic = 61
					communism = 35
					neutrality = 3
					fascism = 1
				}
				set_stability = 0.6
				set_war_support = 0.5
				if = {
					limit = {
						SPD = { controls_state = 41 }
					}
					SPD = { set_capital = { state = 41 } }
				}
				else = {
					random_owned_state = {
						limit = {
							is_controlled_by = SPD
							is_core_of = SPD
							NOT = {
								state = 177
								state = 178
							}
						}
						SPD = {
							set_capital = { state = PREV }
						}
					}
				}
			}
			add_stability = -0.1
			transfer_units_fraction = {
				target = SPD
				stockpile_ratio = 0.4
				army_ratio = 0.3
				navy_ratio = 0.3
				air_ratio = 0.3
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					has_trait = trait_SPR_anti_stalinist_loyalties
				}
			}
			
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_republican_loyalties
				}
				remove_unit_leader_trait = trait_SPR_republican_loyalties
				set_nationality = {
					character = THIS
					target_country = SPD
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_stalinist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPD
				}
			}
			every_unit_leader = {
				limit = {
					has_id = 1108
				}
				set_nationality = {
					character = THIS
					target_country = SPD
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_anti_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
			}
			SPD = {
				every_unit_leader = {
					limit = {
						has_trait = trait_SPR_republican_loyalties
					}
					remove_unit_leader_trait = trait_SPR_republican_loyalties
				}
				every_unit_leader = {
					limit = {
						has_trait = trait_SPR_stalinist_loyalties
					}
					remove_unit_leader_trait = trait_SPR_stalinist_loyalties
				}
				declare_war_on = {
				    target = SPA
				    type = civil_war
				}
				add_civil_war_target = SPA

				add_ai_strategy = {
					type = antagonize
					id = SPA
					value = 200
				}
				declare_war_on = {
				    target = SPC
				    type = civil_war
				}
				add_civil_war_target = SPC

				add_ai_strategy = {
					type = antagonize
					id = SPC
					value = 200
				}
				if = {
					limit = {
						country_exists = SPB
					}
					declare_war_on = {
					    target = SPB
					    type = civil_war
					}
					add_civil_war_target = SPB

					add_ai_strategy = {
						type = antagonize
						id = SPB
						value = 200
					}
				}
			}
			SPD = {
				every_possible_country = {
					limit = {
						has_character = SPR_manuel_azana	
					}
					SPR_manuel_azana = { set_nationality = SPD }
				}
				IF = {
					limit = {
						NOT = {
							has_country_leader = {
								character = SPR_manuel_azana
								ruling_only = yes
							}
						}
					}
					IF = {
						limit = {
							NOT = {
								can_be_country_leader = SPR_manuel_azana
							}
						}
						add_country_leader_role = {
							character = SPR_manuel_azana
							country_leader = {
							 	ideology = conservatism
							 	traits = { figurehead_president }
							 	expire = "1965.1.1"
							}
							promote_leader = yes
						}
					}
					ELSE = {
						promote_character = {
						    character = SPR_manuel_azana
						    ideology = conservatism
						}
					}
				}
				load_focus_tree = {
					tree = spanish_focus
					keep_completed = no
				}
				unlock_national_focus = SPR_the_popular_front
				if = {
					limit = {
						SPC = { has_completed_focus = SPR_secure_the_guardia_civil }
					}
					unlock_national_focus = SPR_secure_the_guardia_civil
				}
				if = {
					limit = {
						SPC = { has_completed_focus = SPR_secure_the_guardia_de_asalto }
					}
					unlock_national_focus = SPR_secure_the_guardia_de_asalto
				}
				unlock_national_focus = SPR_train_the_union_youth
				unlock_national_focus = SPR_enlarge_the_weapon_caches
				unlock_national_focus = SPR_distribute_arms_to_the_people
				unlock_national_focus = SPR_disband_the_army
				complete_national_focus = SPR_maintain_the_second_republic
				complete_national_focus = SPR_new_leadership
				complete_national_focus = SPR_the_future_of_the_republic
				complete_national_focus = SPR_reaffirm_the_popular_front_strategy
				unlock_national_focus = SPR_crush_the_revolution
				add_timed_idea = { idea = SPR_death_before_surrender days = 900 }
			}

			## SPC triggers Anarchist Uprising ##
			### Foreign aid goes to SPD ###
			#Op. modifier goes to SPD.
			if = {
				limit = {
					has_opinion_modifier = POR_helped_in_civil_war
				}
				remove_opinion_modifier = {
					target = POR
					modifier = POR_helped_in_civil_war
				}
				SPD = {
					add_opinion_modifier = {
					    target = POR
					    modifier = POR_helped_in_civil_war
					}
				}
			}
			if = { #Country supporting SPD
				limit = {
					any_country = { has_country_flag = supports_SPD_flag }
				}
				every_country = {
					limit = {
						 has_country_flag = supports_SPD_flag
					}
					diplomatic_relation = {
						country = SPD
						relation = military_access
						active = yes
					}
					SPD = {
						diplomatic_relation = {
							country = PREV
							relation = military_access
							active = yes
						}
					}
					#Join war against all SPD enemies
					every_country = {
						limit = { has_war_with = SPD }
						PREV = {
							add_to_war = {
								targeted_alliance = SPD
								enemy = PREV
								hostility_reason = asked_to_join
							}
						}
					}
				}
				#Transfer troops in territory belonging to SPD allies back home
				every_state = {
					limit = {
						NOT = { is_fully_controlled_by = ROOT }
						owner = {
							has_war_together_with = SPD
						}
					}
					teleport_armies = {
						limit = { 
							tag = SPC
						}
						to_state_array = owned_controlled_states
					}
				}
				if = { #Portuguese Non-aligned tag (spawned via Workers of Iberia, Unite! focus) will join war
					limit = {
						any_country = { has_country_flag = POR_non_aligned_portugal_supports_SPA_flag }
					}
					random_country = {
						limit = {
							has_country_flag = POR_non_aligned_portugal_supports_SPA_flag
						}
						add_to_war = { targeted_alliance = SPA enemy = SPD hostility_reason = asked_to_join }
					}
				}
			}
			if = {	#Country supporting SPA
				limit = {
					any_country = { has_country_flag = supports_SPA_flag }
				}
				every_country = {# Country joins war against SPD
					limit = { has_country_flag = supports_SPA_flag }
					add_to_war = { targeted_alliance = SPA enemy = SPD hostility_reason = asked_to_join }
				}
			}
			if = {	#Country supporting SPB
				limit = {
					any_country = { has_country_flag = supports_SPB_flag }
				}
				every_country = {# Country joins war against SPD
					limit = { has_country_flag = supports_SPB_flag }
					add_to_war = { targeted_alliance = SPB enemy = SPD hostility_reason = asked_to_join }
				}
			}

			#Transfer Portuguese revolted ships (if any) to Republican Spain
			if = {
				limit = {
					SPC = { has_country_flag = POR_got_portuguese_mutineers_flag }
				}
				SPC = {
					if = {
						limit = {
							check_variable = { POR.POR_ships_revolted > 0 }
						}
						SPD = {	set_country_flag = POR_got_portuguese_mutineers_flag }
						transfer_ship = {
							type = destroyer
							prefer_name = "NRP Dão"
							target = SPD
						}
						POR = {
							if = {
								limit = {
									check_variable = { POR.POR_ships_revolted > 1 }
								}
								ROOT = {
									transfer_ship = {
										type = destroyer
										prefer_name = "NRP Douro"
										target = SPD
									}
								}
								if = {
									limit = {
										check_variable = { POR.POR_ships_revolted > 2 }
									}
									ROOT = {
										transfer_ship = {
											type = destroyer
											prefer_name = "NRP Tejo"
											target = SPD
										}
									}
									if = {
										limit = {
											check_variable = { POR.POR_ships_revolted > 3 }
										}
										ROOT = {
											transfer_ship = {
												type = destroyer
												prefer_name = "NRP Tamega"
												target = SPD
											}
										}
									}
								}
							}
						}
					}
					clr_country_flag = POR_got_portuguese_mutineers_flag
				}
			}
			every_state = {
				limit = {
					has_state_flag = SPR_core_of_spain_flag
				}
				add_core_of = SPC
				add_core_of = SPD
			}
			news_event = { id = lar_news.11 days = 1 }
		}
	}
	
	option = {
		name = lar_spain.10.a
		effect_tooltip = {
			if = {
				limit = {
					has_completed_focus = SPR_regional_defense_council_of_aragon
					NOT = { has_government = neutrality }
				}
				set_politics = {
					ruling_party = neutrality
				}
				create_country_leader = {
					name = "Anarchist Commune"
					desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
					picture = "GFX_portrait_SPR_anarchist_commune"
					expire = "1965.1.1"
					ideology = anarchism
					traits = {
						our_right_to_survive
					}
				}
				add_popularity = {
				    ideology = fascism
				    popularity = -1
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.15
				}
				if = {
					limit = {
						democratic > 0.01
					}
					set_political_party = {
					    ideology = democratic
					    popularity = 1
					}
				}
			}
			if = {
				limit = {
					has_completed_focus = SPR_the_anti_fascist_workers_revolution
					NOT = { has_government = communism }
				}
				set_politics = {
					ruling_party = communism
				}
				create_country_leader = {
					name = "Julián Gorkin"
					desc = "POLITICS_JULIAN_GORKIN_DESC"
					picture = "GFX_portrait_SPR_julian_gorkin"
					expire = "1965.1.1"
					ideology = anarchist_communism
					traits = {
						militant_socialist
					}
				}
				add_popularity = {
				    ideology = fascism
				    popularity = -1
				}
				add_popularity = {
				    ideology = communism
				    popularity = -0.05
				}
				if = {
					limit = {
						democratic > 0.01
					}
					set_political_party = {
					    ideology = democratic
					    popularity = 1
					}
				}
			}
			remove_ideas = SPR_the_maximum_concession
			add_ideas = closed_economy
			add_stability = -0.1
			transfer_units_fraction = {
				target = SPD
				stockpile_ratio = 0.4
				army_ratio = 0.3
				navy_ratio = 0.3
				air_ratio = 0.3
				keep_unit_leaders = {
				    
				}
				keep_unit_leaders_trigger = {
					has_trait = trait_SPR_anti_stalinist_loyalties
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_republican_loyalties
				}
				remove_unit_leader_trait = trait_SPR_republican_loyalties
				set_nationality = {
					character = THIS
					target_country = SPD
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_stalinist_loyalties
				set_nationality = {
					character = THIS
					target_country = SPD
				}
			}
			every_unit_leader = {
				limit = {
					has_trait = trait_SPR_anti_stalinist_loyalties
				}
				remove_unit_leader_trait = trait_SPR_anti_stalinist_loyalties
			}
			SPD = {
				declare_war_on = {
				    target = SPA
				    type = civil_war
				}
				add_civil_war_target = SPA
				declare_war_on = {
				    target = SPC
				    type = civil_war
				}
				add_civil_war_target = SPC
				if = {
					limit = {
						country_exists = SPB
					}
					declare_war_on = {
					    target = SPB
					    type = civil_war
					}
					add_civil_war_target = SPB
				}
			}
		}
	}
}

# Spanish Civil War - Carlists Defeated
country_event = {
	id = lar_spain.11
	title = lar_spain.11.t
	desc = lar_spain.11.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.11.a
	}
}

# Spanish Civil War - Fascists Defeated
country_event = {
	id = lar_spain.12
	title = lar_spain.12.t
	desc = lar_spain.12.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.11.a
	}
}

# Spanish Civil War - Franco Defeated
country_event = {
	id = lar_spain.13
	title = lar_spain.13.t
	desc = lar_spain.13.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.11.a
	}
}

# Spanish Civil War - Anarchists Defeated
country_event = {
	id = lar_spain.14
	title = lar_spain.14.t
	desc = lar_spain.14.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.11.a
	}
}

# Spanish Civil War - Independent Communists Defeated
country_event = {
	id = lar_spain.15
	title = lar_spain.15.t
	desc = lar_spain.15.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.11.a
	}
}

# Spanish Civil War - Republicans Defeated
country_event = {
	id = lar_spain.16
	title = lar_spain.16.t
	desc = lar_spain.16.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes

	option = {
		name = lar_spain.11.a
	}
}

# Spanish Civil War - Stalinist Communists Defeated
country_event = {
	id = lar_spain.17
	title = lar_spain.17.t
	desc = lar_spain.17.desc
	picture = GFX_report_event_spr_civil_war_faction_defeated
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.11.a
	}
}

# Spain - Nationalists out of focuses to take, have to 'lay low' for a while
country_event = {
	id = lar_spain.18
	title = lar_spain.18.t
	desc = lar_spain.18.desc
	picture = GFX_report_event_spr_nationalist_soldiers
	
	trigger = {
		tag = SPR
		has_completed_focus = SPA_a_great_spain
		NOT = { has_global_flag = spanish_civil_war }
		NOT = { has_global_flag = scw_over }
		date > 1936.8.10
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes
	
	option = {
		name = lar_spain.18.a
		add_ideas = SPA_awaiting_the_rebellion
		custom_effect_tooltip = lar_spain.18.a_tt
	}
}

# Reassert American Dominance - Event for American nations
country_event = {
	id = lar_spain.19
	title = lar_spain.19.t
	desc = lar_spain.19.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.19.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				strength_ratio = { tag = FROM ratio > 1 }
			}
		}
		effect_tooltip = {
			FROM = { puppet = ROOT }
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.20 hours = 18 random_hours = 6 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.19.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.5 }
			}
			modifier = {
				factor = 0.8
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.3 }
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.2 }
			}
			modifier = {
				factor = 0.5
				strength_ratio = { tag = FROM ratio < 0.1 }
			}
		}
		effect_tooltip = {
			FROM = {
				create_wargoal = {
				    type = puppet_wargoal_focus
				    target = ROOT
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.21 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Reassert American Dominance - Notification event for Spain - Target Accepted
country_event = {
	id = lar_spain.20
	title = lar_spain.20.t
	desc = lar_spain.20.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.20.a
		puppet = FROM
	}
}

# Reassert American Dominance - Notification event for Spain - Target Declined
country_event = {
	id = lar_spain.21
	title = lar_spain.21.t
	desc = lar_spain.21.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.21.a
		create_wargoal = {
		    type = puppet_wargoal_focus
		    target = FROM
		}
	}
}

# Portuguese Aid - Event for Portugal
country_event = {
	id = lar_spain.22
	title = lar_spain.22.t
	desc = lar_spain.22.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.22.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				has_completed_focus = POR_popular_front
			}
			modifier = {
				factor = 0
				has_completed_focus = POR_strict_neutrality_in_the_spanish_civil_war
			}
		}
		add_manpower = -20000
		effect_tooltip = {
			FROM = { add_manpower = 20000 }
		}
		add_timed_idea = { idea = SPA_spanish_civil_war_commitments days = 730 }
		add_opinion_modifier = { target = ROOT modifier = SPA_spanish_civil_war_commitments }
		add_ai_strategy = {
			type = send_volunteers_desire
			id = SPA
			value = 200
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.23 hours = 18 random_hours = 6 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.22.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0.5
				has_completed_focus = POR_support_the_spanish_nationalists
			}
			modifier = {
				factor = 0
				has_completed_focus = POR_send_assistance
			}
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.24 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Portuguese Aid - Event for Spain - POR accepted
country_event = {
	id = lar_spain.23
	title = lar_spain.23.t
	desc = lar_spain.23.desc
	picture = GFX_report_event_soldiers_marching
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.23.a
		effect_tooltip = {
			POR = {
				add_timed_idea = { idea = SPA_spanish_civil_war_commitments days = 730 }
				add_opinion_modifier = { target = ROOT modifier = SPA_spanish_civil_war_commitments }
			}
		}
		add_manpower = 20000
	}
}

# Portuguese Aid - Event for Spain - POR declined
country_event = {
	id = lar_spain.24
	title = lar_spain.24.t
	desc = lar_spain.24.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.24.a
	}
}

# Iberian Pact - Event for Portugal
country_event = {
	id = lar_spain.25
	title = lar_spain.25.t
	desc = lar_spain.25.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.25.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				has_completed_focus = POR_popular_front
			}
		}
		custom_effect_tooltip = SPA_the_iberian_pact_tt
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.26 hours = 18 random_hours = 6 }
			}
		}
		if= { #If Portugal is in faction, Spain will join
			limit = {
				is_in_faction = yes
				FROM = { is_in_faction = no }
			}
			effect_tooltip = {
				random_other_country = {
					limit = {
						is_in_faction_with = ROOT
						is_faction_leader = yes
					}
					add_to_faction = FROM
				}
			}
		}
		else_if = { #If Spain is in faction, Portugal will join
			limit = {
				is_in_faction = no
				FROM = { is_in_faction = yes }
			}
			random_other_country = {
				limit = {
					is_in_faction_with = FROM
					is_faction_leader = yes
				}
				add_to_faction = ROOT
			}
		}
		else_if = { #If Spain and Portugal are in different factions, both will leave their faction
			limit = {
				is_in_faction = yes
				FROM = { is_in_faction = yes }
				NOT = { is_in_faction_with = FROM }
			}
			effect_tooltip = {
				leave_faction = yes
				FROM = { leave_faction = yes }
			}
		}
	}

	option = { # Decline
		name = lar_spain.25.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0.5
				has_completed_focus = POR_support_the_spanish_nationalists
			}
			modifier = {
				factor = 0
				focus_progress = {
				    focus = POR_iberian_summit
				    progress > 0
				}
			}
			modifier = {
				factor = 0
				has_completed_focus = POR_support_the_spanish_nationalists
				is_historical_focus_on = yes
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.27 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Iberian Pact - Event for Spain - POR accepted
country_event = {
	id = lar_spain.26
	title = lar_spain.25.t
	desc = lar_spain.26.desc
	picture = GFX_report_event_generic_sign_treaty1
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.26.a
		custom_effect_tooltip = SPA_the_iberian_pact_tt
		if= { #If Spain is in faction, Portugal will join
			limit = {
				is_in_faction = yes
				FROM = { is_in_faction = no }
			}
			effect_tooltip = {
				random_other_country = {
					limit = {
						is_in_faction_with = ROOT
						is_faction_leader = yes
					}
					add_to_faction = FROM
				}
			}
		}
		else_if = { #If Portugal is in faction, Spain will join
			limit = {
				is_in_faction = no
				FROM = { is_in_faction = yes }
			}
			random_other_country = {
				limit = {
					is_in_faction_with = FROM
					is_faction_leader = yes
				}
				add_to_faction = ROOT
			}
		}
		else_if = { #If Spain and Portugal are in different factions, both will leave their faction
			limit = {
				is_in_faction = yes
				FROM = { is_in_faction = yes }
				NOT = { is_in_faction_with = FROM }
			}
			leave_faction = yes
			FROM = { leave_faction = yes }
		}
		hidden_effect = {
			FROM = { set_country_flag = SPA_iberian_pact }
			set_country_flag = SPA_iberian_pact
		}
	}
}

# Iberian Pact - Event for Spain - POR declined
country_event = {
	id = lar_spain.27
	title = lar_spain.25.t
	desc = lar_spain.27.desc
	picture = GFX_report_event_generic_sign_treaty1
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.27.a
	}
}

# Iberian Pact - Other party has joined a faction, we must uphold our end of the bargain!
country_event = {
	id = lar_spain.28
	title = lar_spain.28.t
	desc = lar_spain.28.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			random_other_country = {
				limit = {
					has_country_flag = SPA_iberian_pact_invitee
				}
				save_event_target_as = iberian_pact_invitee
			}
			random_other_country = {
				limit = {
					has_country_flag = SPA_iberian_pact_faction_leader
				}
				add_to_faction = ROOT
			}
		}
	}
	
	option = { # OK
		name = lar_spain.28.a
		effect_tooltip = {
			random_other_country = {
				limit = {
					is_in_faction_with = event_target:iberian_pact_invitee
					is_faction_leader = yes
				}
				add_to_faction = ROOT
			}
		}
	}
}

# Iberian Pact - Other party has joined the war, we must uphold our end of the bargain!
country_event = {
	id = lar_spain.29
	title = lar_spain.28.t
	desc = lar_spain.29.desc
	picture = GFX_report_event_generic_parliament

	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.28.a
		random_other_country = {
			limit = {
				has_war_with = event_target:iberian_pact_war_target
				if = {
					limit = {
						any_country = {
							has_country_flag = SPA_iberian_pact_enemy_flag
						}
					}
					has_country_flag = SPA_iberian_pact_enemy_flag
				}
			}
			random_other_country = {
				limit = {
					has_country_flag = SPA_iberian_pact
					has_war_with = PREV
				}
				ROOT = {
					add_to_war = { 
					    targeted_alliance = PREV
					    enemy = PREV.PREV
					    hostility_reason = asked_to_join
					}
				}
			}
		}
	}
}

# Latin Bloc - Event for invitees
country_event = {
	id = lar_spain.30
	title = lar_spain.30.t
	desc = lar_spain.30.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.30.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				has_government = democratic
				FROM = { has_government = fascism }
			}
			modifier = {
				factor = 0
				has_government = communism
			}
		}
		effect_tooltip = {
			FROM = {
				add_to_faction = ROOT
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.31 hours = 18 random_hours = 6 }
			}
			add_ai_strategy = {
				type = alliance
				id = FROM
				value = 200
			}
		}
	}

	option = { # Decline
		name = lar_spain.30.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0
				has_government = FROM
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.32 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Latin Bloc - Event for Spain - FROM accepted
country_event = {
	id = lar_spain.31
	title = lar_spain.30.t
	desc = lar_spain.31.desc
	picture = GFX_report_event_generic_sign_treaty2
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.31.a
		add_to_faction = FROM
	}
}

# Latin Bloc - Event for Spain - FROM declined
country_event = {
	id = lar_spain.32
	title = lar_spain.30.t
	desc = lar_spain.32.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.32.a
	}
}

# Spain - Contact the Union Militar Espanola
country_event = {
	id = lar_spain.33
	title = lar_spain.33.t
	desc = lar_spain.33.desc
	picture = GFX_report_event_spr_carlists2
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			random_owned_state = {
				limit = {
					is_core_of = ROOT
					is_controlled_by = ROOT
					NOT = {
						state = 177
						state = 178
					}
					NOT = { has_state_flag = SPA_carlist_cell_flag }
				}
				set_state_flag = union_militar_temp_flag_1
				save_event_target_as = union_militar_target_state_1
			}
			random_owned_state = {
				limit = {
					is_core_of = ROOT
					is_controlled_by = ROOT
					NOT = {
						state = 177
						state = 178
					}
					NOT = { has_state_flag = SPA_carlist_cell_flag }
					NOT = { has_state_flag = union_militar_temp_flag_1 }
				}
				set_state_flag = union_militar_temp_flag_2
				save_event_target_as = union_militar_target_state_2
			}
			random_owned_state = {
				limit = {
					is_core_of = ROOT
					is_controlled_by = ROOT
					NOT = {
						state = 177
						state = 178
					}
					NOT = { has_state_flag = SPA_carlist_cell_flag }
					NOT = { has_state_flag = union_militar_temp_flag_1 }
					NOT = { has_state_flag = union_militar_temp_flag_2 }
				}
				set_state_flag = union_militar_temp_flag_3
				save_event_target_as = union_militar_target_state_3
			}
		}
	}
	
	option = { # Choose First State
		name = lar_spain.33.a
		trigger = {
			any_owned_state = {
				has_state_flag = union_militar_temp_flag_1
			}
		}
		random_owned_state = {
			limit = {
				has_state_flag = union_militar_temp_flag_1
			}
			custom_effect_tooltip = lar_spain.33_tt
			hidden_effect = {
				set_state_flag = SPA_union_militar_flag
			}
		}
	}

	option = { # Choose Second State
		name = lar_spain.33.b
		trigger = {
			any_owned_state = {
				has_state_flag = union_militar_temp_flag_2
			}
		}
		random_owned_state = {
			limit = {
				has_state_flag = union_militar_temp_flag_2
			}
			custom_effect_tooltip = lar_spain.33_tt
			hidden_effect = {
				set_state_flag = SPA_union_militar_flag
			}
		}
	}

	option = { # Choose Third State
		name = lar_spain.33.c
		trigger = {
			any_owned_state = {
				has_state_flag = union_militar_temp_flag_3
			}
		}
		random_owned_state = {
			limit = {
				has_state_flag = union_militar_temp_flag_3
			}
			custom_effect_tooltip = lar_spain.33_tt
			hidden_effect = {
				set_state_flag = SPA_union_militar_flag
			}
		}
	}
}

# Spain - Settle the Succession Question
country_event = {
	id = lar_spain.34
	title = lar_spain.34.t
	desc = lar_spain.34.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Choose first King
		name = lar_spain.34.a
		ai_chance = {
			base = 66
		}
		set_country_flag = SPB_xavier_king
		custom_effect_tooltip = lar_spain.34.a_tt
	}

	option = { # Choose second King
		name = lar_spain.34.b
		ai_chance = {
			base = 34
		}
		custom_effect_tooltip = lar_spain.34.b_tt
	}
}

# Spain - Restore the Monarchy - ### DEPRECATED, replaced by News Event ###
country_event = {
	id = lar_spain.35
	title = lar_spain.35.t
	desc = lar_spain.35.desc
	picture = GFX_report_event_royal_parade
	
	is_triggered_only = yes
	
	option = { # Establish Monarchy
		name = lar_spain.35.a
		drop_cosmetic_tag = yes
		set_cosmetic_tag = SPB_kingdom
		if = {
			limit = {
				has_country_flag = SPB_xavier_king
			}
			create_country_leader = {
				name = "Javier I"
				desc = "POLITICS_JAVIER_I_DESC"
				picture = "GFX_portrait_SPA_xavier_of_bourbon_parma"
				expire = "1965.1.1"
				ideology = despotism
				traits = {
					the_sacred_king
				}
			}
		}
		if = {
			limit = {
				NOT = { has_country_flag = SPB_xavier_king }
				NOT = { has_global_flag = SPB_alfonso_xiii_dead }
			}
			create_country_leader = {
				name = "Alfonso XIII"
				desc = "POLITICS_ALFONSO_XIII_DESC"
				picture = "GFX_portrait_SPA_alfonso_xiii"
				expire = "1965.1.1"
				ideology = despotism
				traits = {
					disgraced_monarch
				}
			}
		}
		if = {
			limit = {
				NOT = { has_country_flag = SPB_xavier_king }
				has_global_flag = SPB_alfonso_xiii_dead
			}
			create_country_leader = {
				name = "Jaime IV"
				desc = "POLITICS_JAIME_IV_DESC"
				picture = "GFX_portrait_fra_infante_jaime"
				expire = "1965.1.1"
				ideology = despotism
				traits = {
					the_legitimist
				}
			}
		}
	}
}

# Tangiers Enclave - Event for UK
country_event = {
	id = lar_spain.36
	title = lar_spain.36.t
	desc = lar_spain.36.desc
	picture = GFX_report_event_spr_occupation_of_tangiers
	
	is_triggered_only = yes
	
	option = { # Protest
		name = lar_spain.36.a
		ai_chance = {
			base = 34
			modifier = {
				factor = 3
				has_war = no
			}
			modifier = {
				factor = 2
				has_government = democratic
			}
			modifier = {
				factor = 5
				strength_ratio = {
				    tag = FROM
				    ratio > 5
				}
			}
			modifier = {
				factor = 2
				strength_ratio = {
				    tag = FROM
				    ratio > 3
				}
			}
			modifier = {
				factor = 0.5
				strength_ratio = {
				    tag = FROM
				    ratio < 2
				}
			}
			modifier = {
				factor = 0.5
				NOT = { has_political_power > 100 }
			}
			modifier = {
				factor = 0
				strength_ratio = {
				    tag = FROM
				    ratio < 1
				}
			}
			modifier = {
				factor = 0
				is_in_faction_with = FROM
			}
		}
		add_political_power = -200
		custom_effect_tooltip = lar_spain.36_tt
		effect_tooltip = {
			create_wargoal = {
			    type = topple_government
			    target = FROM
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.37 hours = 18 random_hours = 6 }
			}
		}
	}

	option = { # Let it slide
		name = lar_spain.36.b
		ai_chance = {
			base = 66
			modifier = {
				factor = 10
				has_war = yes
			}
			modifier = {
				factor = 5
				has_government = fascism
			}
			modifier = {
				factor = 10
				surrender_progress > 0.1
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.38 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Tangiers Enclave - Event for Spain - UK protested
country_event = {
	id = lar_spain.37
	title = lar_spain.36.t
	desc = lar_spain.37.desc
	picture = GFX_report_event_spr_occupation_of_tangiers
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.37.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		FROM = {
			create_wargoal = {
			    type = topple_government
			    target = ROOT
			}
		}
		290 = {
			add_extra_state_shared_building_slots = 3
			add_building_construction = {
				type = industrial_complex
				level = 2
				instant_build = yes
			}
		}
	}

	option = { # We must back down
		name = lar_spain.37.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				strength_ratio = {
				    tag = FROM
				    ratio > 0.6
				}
			}
		}
	}
}

# Tangiers Enclave - Event for Spain - UK let it slide
country_event = {
	id = lar_spain.38
	title = lar_spain.36.t
	desc = lar_spain.38.desc
	picture = GFX_report_event_spr_occupation_of_tangiers
	
	is_triggered_only = yes
	
	option = { # OK
		name = lar_spain.38.a
		290 = {
			add_extra_state_shared_building_slots = 3
			add_building_construction = {
				type = industrial_complex
				level = 2
				instant_build = yes
			}
		}
	}
}

# Demand French North Africa - Event for France
country_event = {
	id = lar_spain.39
	title = lar_spain.39.t
	desc = lar_spain.39.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.39.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				strength_ratio = { tag = FROM ratio > 1 }
			}
			modifier = {
				factor = 5
				NOT = { has_war_with = FROM }
				has_war = yes
			}
		}
		effect_tooltip = {
			FROM = {
				transfer_state = 461
				transfer_state = 462
				transfer_state = 459
				transfer_state = 460
				transfer_state = 513
				transfer_state = 514
				transfer_state = 458
				transfer_state = 665
			}
		}
		hidden_effect = {
			set_country_flag = surrendered_french_north_africa
			FROM = {
				country_event = { id = lar_spain.40 hours = 18 random_hours = 6 }
			}
			news_event = { id = lar_news.14 days = 2 }
		}
	}

	option = { # Decline
		name = lar_spain.39.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.5 }
			}
			modifier = {
				factor = 0.8
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.3 }
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.2 }
			}
			modifier = {
				factor = 0
				strength_ratio = { tag = FROM ratio < 0.1 }
			}
			modifier = {
				factor = 0
				has_focus_tree = vichy_french_focus
				NOT = { has_war_with = GER }
				FROM = { is_in_faction_with = GER }
			}
		}
		effect_tooltip = {
			FROM = {
				add_state_claim = 461
				add_state_claim = 462
				add_state_claim = 459
				add_state_claim = 460
				add_state_claim = 513
				add_state_claim = 514
				add_state_claim = 458
				add_state_claim = 665
				create_wargoal = {
					type = take_state_focus
					target = ROOT
					generator = { 461 462 459 460 513 514 458 665 }
					expire = 0
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.41 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Demand French North Africa - Event for Spain - France accepted
country_event = {
	id = lar_spain.40
	title = lar_spain.40.t
	desc = lar_spain.40.desc
	picture = GFX_report_event_generic_sign_treaty3
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.40.a
		transfer_state = 461
		transfer_state = 462
		transfer_state = 459
		transfer_state = 460
		transfer_state = 513
		transfer_state = 514
		transfer_state = 458
		transfer_state = 665
	}
}

# Demand French North Africa - Event for Spain - France declined
country_event = {
	id = lar_spain.41
	title = lar_spain.41.t
	desc = lar_spain.41.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.41.a
		add_state_claim = 461
		add_state_claim = 462
		add_state_claim = 459
		add_state_claim = 460
		add_state_claim = 513
		add_state_claim = 514
		add_state_claim = 458
		add_state_claim = 665
		create_wargoal = {
			type = take_state_focus
			target = FROM
			generator = { 461 462 459 460 513 514 458 665 }
			expire = 0
		}
	}
}

# Claim the French Throne - Event for France
country_event = {
	id = lar_spain.42
	title = lar_spain.42.t
	desc = lar_spain.42.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.42.a
		ai_chance = {
			base = 5
			modifier = {
				factor = 0
				has_war = no
				strength_ratio = { tag = FROM ratio > 0.5 }
			}
		}
		effect_tooltip = {
			FROM = {
				annex_country = { target = ROOT transfer_troops = yes }
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.43 hours = 18 random_hours = 6 }
			}
			news_event = { id = lar_news.15 days = 2 }
		}
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { # Decline
		name = lar_spain.42.b
		ai_chance = {
			base = 95
			modifier = {
				factor = 0
				focus_progress = {
					focus = FRA_the_legitimate_heir
					progress > 0
				}
			}
			modifier = {
				factor = 0.8
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.1
			}
			modifier = {
				factor = 0.5
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.3
			}
			modifier = {
				factor = 0.5
				strength_ratio = { tag = FROM ratio < 0.2 }
			}
			modifier = {
				factor = 0.2
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.5
			}
		}
		effect_tooltip = {
			FROM = {
				create_wargoal = {
					type = annex_everything
					target = ROOT
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.44 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Claim the French Throne - Event for Spain - France accepted
country_event = {
	id = lar_spain.43
	title = lar_spain.43.t
	desc = lar_spain.43.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.43.a
		puppet = FROM
		custom_effect_tooltip = lar_spain.43_tt
		hidden_effect = { country_event = { id = lar_spain.79 days = 7 random_days = 7 } }
	}
}

# Claim the French Throne - Event for Spain - France declined
country_event = {
	id = lar_spain.44
	title = lar_spain.44.t
	desc = lar_spain.44.desc
	picture = GFX_report_event_read_write
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.44.a
		create_wargoal = {
			type = annex_everything
			target = FROM
		}
	}
}

# Iberian Union - Event for Portugal
country_event = {
	id = lar_spain.45
	title = lar_spain.45.t
	desc = lar_spain.45.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.45.a
		ai_chance = {
			base = 5
			modifier = {
				factor = 0
				FROM = { is_ai = no }
				has_war = no
				strength_ratio = { tag = FROM ratio > 0.5 }
				NOT = { is_puppet_of = FROM }
			}
			modifier = {
				factor = 5
				has_opinion = { target = FROM value > 99 }
			}
		}
		effect_tooltip = {
			FROM = {
				annex_country = { target = ROOT transfer_troops = yes }
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.46 hours = 18 random_hours = 6 }
			}
			news_event = { id = lar_news.16 days = 2 }
		}
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { # Decline
		name = lar_spain.45.b
		ai_chance = {
			base = 95
			modifier = {
				factor = 0
				FROM = { is_ai = yes }
			}
			modifier = {
				factor = 0.1
				has_completed_focus = POR_the_royal_iberian_alliance
			}
			modifier = {
				factor = 0.8
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.1
			}
			modifier = {
				factor = 0.5
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.3
			}
			modifier = {
				factor = 0.5
				strength_ratio = { tag = FROM ratio < 0.2 }
			}
			modifier = {
				factor = 0
				OR = {
					AND = {
						NOT = { has_war_with = FROM }
						has_war = yes
						surrender_progress > 0.5
					}
					is_puppet_of = FROM
				}
			}
		}
		effect_tooltip = {
			FROM = {
				create_wargoal = {
					type = annex_everything
					target = ROOT
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.47 hours = 18 random_hours = 6 }
			}
		}
	}
}

# Iberian Union - Event for Spain - Portugal Accepted
country_event = {
	id = lar_spain.46
	title = lar_spain.46.t
	desc = lar_spain.46.desc
	picture = GFX_report_event_generic_sign_treaty3
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.46.a
		set_cosmetic_tag = ESU_POR_unified
		every_state = {
			limit = {
				is_core_of = POR
			}
			add_core_of = ROOT
		}
		annex_country = { target = FROM transfer_troops = yes }
	}
}

# Iberian Union - Event for Spain - Portugal Declined
country_event = {
	id = lar_spain.47
	title = lar_spain.47.t
	desc = lar_spain.47.desc
	picture = GFX_report_event_generic_sign_treaty2
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.47.a
		create_wargoal = {
			type = annex_everything
			target = FROM
		}
	}
}

# Portuguese Anarchism - Event for Portugal
country_event = {
	id = lar_spain.48
	title = lar_spain.48.t
	desc = lar_spain.48.desc
	picture = GFX_report_event_spr_anarchist_uprising
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			random_owned_state = {
				limit = {
					any_neighbor_state = {
						is_fully_controlled_by = SPC
					}
				}
				set_state_flag = SPC_portuguese_anarchism_state
			}
			set_global_flag = SPR_portuguese_anarchism_flag
		}
	}
	
	option = { # Ok :'(
		name = lar_spain.48.a
		hidden_effect = {
			start_civil_war = {
			    ideology = communism
			    size = 0.1
			    states_filter = { 
			        has_state_flag = SPC_portuguese_anarchism_state
			    }
			    keep_unit_leaders_trigger = {
			    	always = yes
			    }
			}
			random_country = {
				limit = {
					original_tag = POR
					has_government = communism
					NOT = { tag = ROOT }
				}
				set_politics = {
					ruling_party = neutrality
				}
				set_political_party = {
				    ideology = neutrality
				    popularity = 100
				}
				set_party_name = { ideology = neutrality long_name = SPR_neutrality_anarchism_party_long name = SPR_neutrality_anarchism_party }
				set_cosmetic_tag = SPR_POR_anarchism
				set_country_flag = SPR_portuguese_anarchism_flag
				retire_country_leader = yes
				create_country_leader = {
					name = "Anarchist Commune"
					desc = "POLITICS_ANARCHIST_COMMUNE_DESC"
					picture = "GFX_portrait_SPR_anarchist_commune"
					expire = "1965.1.1"
					ideology = anarchism
					traits = {
					}
				}
			}
			FROM = {
				country_event = { id = lar_spain.49 }
			}
		}
	}
}

# Portuguese Anarchism - Event for Spain
country_event = {
	id = lar_spain.49
	title = lar_spain.48.t
	desc = lar_spain.49.desc
	picture = GFX_report_event_spr_anarchist_uprising
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.49.a
		random_country = {
			limit = {
				original_tag = POR
				has_government = neutrality
				NOT = { tag = FROM }
			}
			SPC = {
				add_to_war = {
				    targeted_alliance = PREV 
				    enemy = POR
				    hostility_reason = asked_to_join
				}
				puppet = PREV
			}
			set_political_party = {
			    ideology = neutrality
			    popularity = 100
			}
		}
		POR ={
			set_rule = { can_join_factions = no	}
		}
	}
}

# Portuguese Anarchism - Event for Spain - Portuguese Civil War ends
country_event = {
	id = lar_spain.50
	title = lar_spain.50.t
	desc = lar_spain.50.desc
	picture = GFX_report_event_spr_anarchist_success
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.50.a
		random_country = {
			limit = {
				original_tag = POR
				has_government = neutrality
				is_subject_of = ROOT
			}
			SPC = {
				annex_country = {
				    target = PREV
				    transfer_troops = yes
				}
			}
		}
		clr_global_flag = SPR_portuguese_anarchism_flag
	}
}

# Relocate the Gold Reserves - Event for Spain - Choose target
country_event = {
	id = lar_spain.51
	title = lar_spain.51.t
	desc = lar_spain.51.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			random_other_country = {
				limit = {
					ROOT = {
						has_volunteers_amount_from = {
						    tag = PREV
						    count > 0
						}
					}
					NOT = { tag = SOV }
				}
				set_country_flag = SPR_relocated_gold_reserves_selection_flag1
				save_event_target_as = SPR_relocated_gold_reserves_selection_1
			}
			random_other_country = {
				limit = {
					ROOT = {
						has_volunteers_amount_from = {
						    tag = PREV
						    count > 0
						}
					}
					NOT = { tag = SOV }
					NOT = { has_country_flag = SPR_relocated_gold_reserves_selection_flag1 }
				}
				set_country_flag = SPR_relocated_gold_reserves_selection_flag2
				save_event_target_as = SPR_relocated_gold_reserves_selection_2
			}
			random_other_country = {
				limit = {
					ROOT = {
						has_volunteers_amount_from = {
						    tag = PREV
						    count > 0
						}
					}
					NOT = { tag = SOV }
					NOT = { has_country_flag = SPR_relocated_gold_reserves_selection_flag1 }
					NOT = { has_country_flag = SPR_relocated_gold_reserves_selection_flag2 }
				}
				set_country_flag = SPR_relocated_gold_reserves_selection_flag3
				save_event_target_as = SPR_relocated_gold_reserves_selection_3
			}
		}
	}
	
	option = { # Send to SOV
		name = lar_spain.51.a
		ai_chance = {
			base = 25
			modifier = {
				factor = 2
				has_volunteers_amount_from = {
				    tag = SOV
				    count > 0
				}
			}
		}
		trigger = {
			SOV = {
				exists = yes
				has_government = communism
			}
		}
		SOV = { set_country_flag = SPR_relocated_gold_reserves_selection_flag_sov }
		SOV = { country_event = { id = lar_spain.52 hours = 6 random_hours = 6 } }
	}
	option = { # Send to #1
		name = lar_spain.51.b
		ai_chance = {
			base = 25
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		trigger = {
			any_other_country = {
				has_country_flag = SPR_relocated_gold_reserves_selection_flag1
			}
		}
		event_target:SPR_relocated_gold_reserves_selection_1 = {
			country_event = { id = lar_spain.52 hours = 6 random_hours = 6 }
		}
	}
	option = { # Send to #2
		name = lar_spain.51.c
		ai_chance = {
			base = 25
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		trigger = {
			any_other_country = {
				has_country_flag = SPR_relocated_gold_reserves_selection_flag2
			}
		}
		event_target:SPR_relocated_gold_reserves_selection_2 = {
			country_event = { id = lar_spain.52 hours = 6 random_hours = 6 }
		}
	}
	option = { # Send to #3
		name = lar_spain.51.d
		ai_chance = {
			base = 25
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		trigger = {
			any_other_country = {
				has_country_flag = SPR_relocated_gold_reserves_selection_flag3
			}
		}
		event_target:SPR_relocated_gold_reserves_selection_3 = {
			country_event = { id = lar_spain.52 hours = 6 random_hours = 6 }
		}
	}
}

# Relocate the Gold Reserves - Event for Target
country_event = {
	id = lar_spain.52
	title = lar_spain.52.t
	desc = lar_spain.52.desc
	picture = GFX_report_event_destroyers
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.52.a
		set_country_flag = { flag = SPR_relocate_the_gold_reserves_timer_flag value = 1 days = 60 }
	}
}

# Relocate the Gold Reserves - Event for Target - Seize the Gold
country_event = {
	id = lar_spain.53
	title = lar_spain.53.t
	desc = lar_spain.53.desc
	picture = GFX_report_event_generic_read_write
	
	fire_only_once = yes

	trigger = {
		any_country = {
			original_tag = SPR
			OR = {
				has_government = democratic
				has_government = communism
			}
			has_volunteers_amount_from = {
			    tag = ROOT
			    count > 0
			}
			has_completed_focus = SPR_relocate_the_gold_reserves
		}
		OR = {
			has_country_flag = SPR_relocated_gold_reserves_selection_flag_sov
			has_country_flag = SPR_relocated_gold_reserves_selection_flag1
			has_country_flag = SPR_relocated_gold_reserves_selection_flag2
			has_country_flag = SPR_relocated_gold_reserves_selection_flag3
		}
		NOT = { has_country_flag = SPR_relocate_the_gold_reserves_timer_flag }
	}

	mean_time_to_happen = {
		days = 30
	}
	
	option = { # Seize it!
		name = lar_spain.53.a
		ai_chance = {
			base = 50
		}
		add_political_power = -25
		add_timed_idea = { idea = SPR_seized_spanish_gold_reserves days = 365 }
		hidden_effect = {
			SPD = {
				country_event = { id = lar_spain.54 }
			}
		}
	}

	option = { # Let it go.
		name = lar_spain.53.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
	}
}

# Relocate the Gold Reserves - Event for Spain - Gold seized!
country_event = {
	id = lar_spain.54
	title = lar_spain.54.t
	desc = lar_spain.54.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			remove_ideas = SPR_relocate_the_gold_reserves
			set_country_flag = SPR_seized_gold_reserves_flag
		}
	}
	
	option = { # Ok
		name = lar_spain.54.a
		effect_tooltip = { remove_ideas = SPR_relocate_the_gold_reserves }
		custom_effect_tooltip = lar_spain.54.a_tt
	}
}

# Relocate the Gold Reserves - Event for Spain - Payback time
country_event = {
	id = lar_spain.55
	title = lar_spain.55.t
	desc = lar_spain.55.desc
	picture = GFX_report_event_generic_read_write
	
	fire_only_once = yes

	trigger = {
		original_tag = SPR
		has_country_flag = SPR_seized_gold_reserves_flag
		has_global_flag = scw_over
	}

	mean_time_to_happen = {
		days = 2
	}
	
	option = { # Dangit
		name = lar_spain.55.a
		add_timed_idea = { idea = SPR_seized_spanish_gold_reserves_spain days = 365 }
	}
}

# Appeal for Increased Autonomy - Event for SOV
country_event = {
	id = lar_spain.56
	title = lar_spain.56.t
	desc = lar_spain.56.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.56.a
		end_puppet = FROM
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.57 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.56.b
		ai_chance = {
			base = 0
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.58 }
			}
		}
	}
}

# Appeal for Increased Autonomy - Event for Spain - SOV accepted
country_event = {
	id = lar_spain.57
	title = lar_spain.57.t
	desc = lar_spain.57.desc
	picture = GFX_report_event_generic_sign_treaty3
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.57.a
		effect_tooltip = {
			FROM = { end_puppet = ROOT }
		}
	}
}

# Appeal for Increased Autonomy - Event for Spain - SOV declined
country_event = {
	id = lar_spain.58
	title = lar_spain.58.t
	desc = lar_spain.58.desc
	picture = GFX_report_event_generic_sign_treaty2
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.58.a
	}
}

# A Red Iberia - Event for Portugal
country_event = {
	id = lar_spain.59
	title = lar_spain.59.t
	desc = lar_spain.59.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.59.a
		ai_chance = {
			base = 50
		}
		effect_tooltip = {
			FROM = {
				annex_country = { target = ROOT transfer_troops = yes }
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.60 }
			}
		}
		custom_effect_tooltip = GAME_OVER_TT
	}

	option = { # Decline
		name = lar_spain.59.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				focus_progress = {
				    focus = POR_the_iberian_socialist_union
				    progress > 0
				}
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.5 }
			}
			modifier = {
				factor = 0.8
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.3 }
			}
			modifier = {
				factor = 0.8
				strength_ratio = { tag = FROM ratio < 0.2 }
			}
			modifier = {
				factor = 0
				strength_ratio = { tag = FROM ratio < 0.1 }
			}
			modifier = {
				factor = 0.8
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0
			}
			modifier = {
				factor = 0.5
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.3
			}
			modifier = {
				factor = 0.5
				strength_ratio = { tag = FROM ratio < 0.2 }
			}
			modifier = {
				factor = 0
				NOT = { has_war_with = FROM }
				has_war = yes
				surrender_progress > 0.5
			}
		}
		effect_tooltip = {
			FROM = {
				create_wargoal = {
					type = annex_everything
					target = ROOT
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.61 }
			}
		}
	}
}

# A Red Iberia - Event for Spain - Portugal Accepted
country_event = {
	id = lar_spain.60
	title = lar_spain.60.t
	desc = lar_spain.60.desc
	picture = GFX_report_event_generic_sign_treaty3
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.60.a
		set_cosmetic_tag = ESU_POR_unified
		every_state = {
			limit = {
				is_core_of = POR
			}
			add_core_of = ROOT
		}
		annex_country = { target = FROM transfer_troops = yes }
	}
}

# A Red Iberia - Event for Spain - Portugal Declined
country_event = {
	id = lar_spain.61
	title = lar_spain.61.t
	desc = lar_spain.61.desc
	picture = GFX_report_event_generic_sign_treaty2
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.61.a
		create_wargoal = {
			type = annex_everything
			target = FROM
		}
	}
}

# Support French Communists - Event for France
country_event = {
	id = lar_spain.62
	title = lar_spain.62.t
	desc = lar_spain.62.desc
	picture = GFX_report_event_generic_riot
	
	is_triggered_only = yes
	
	option = { # Ok :'(
		name = lar_spain.62.a
		hidden_effect = {
			if = {
				limit = {
					communism > 0.4
				}
				start_civil_war = {
				    ideology = communism
				    size = 0.3
				    keep_unit_leaders_trigger = {
				    	always = yes
				    }
				}
			}
			else_if = {
				limit = {
					communism > 0.3
				}
				start_civil_war = {
				    ideology = communism
				    size = 0.2
				    keep_unit_leaders_trigger = {
				    	always = yes
				    }
				}
			}
			else = {
				start_civil_war = {
				    ideology = communism
				    size = 0.1
				    keep_unit_leaders_trigger = {
				    	always = yes
				    }
				}
			}
			FROM = {
				country_event = { id = lar_spain.63 }
			}
		}
	}
}

# Support French Communists - Event for Spain
country_event = {
	id = lar_spain.63
	title = lar_spain.63.t
	desc = lar_spain.63.desc
	picture = GFX_report_event_generic_riot
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.63.a
		random_country = {
			limit = {
				original_tag = FRA
				has_government = communism
				NOT = { tag = FROM }
			}
			SPR = {
				puppet = PREV
				add_to_war = { 
				    targeted_alliance = PREV
				    enemy = FRA
				    hostility_reason = asked_to_join
				}
			}
		}
	}
}

# Petition for French Aid - Event for France
country_event = {
	id = lar_spain.64
	title = lar_spain.64.t
	desc = lar_spain.64.desc
	picture = GFX_report_event_spr_no_pasaran
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.64.a
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				is_historical_focus_on = yes
			}
			modifier = {
				factor = 0.2
				has_country_flag = FRA_non_intervention
			}
		}
		add_political_power = -50
		add_popularity = {
			ideology = communism
			popularity = 0.1
		}
		add_timed_idea = { idea = SPR_equipment_shipments days = 730 }
		add_opinion_modifier = { target = FROM modifier = SPA_spanish_civil_war_commitments }
		FROM = {
			add_war_support = 0.15
		}
		add_ai_strategy = { type = send_lend_lease_desire id = SPR value = 100 }
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.65 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.64.b
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				OR = {
					has_country_flag = FRA_arms_purchases_allowed
					has_country_flag = FRA_sending_weapons_allowed
					has_country_flag = FRA_volunteer_work_allowed
				}
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.66 }
			}
		}
	}
}

# Petition for French Aid - Event for Spain - France Accepted
country_event = {
	id = lar_spain.65
	title = lar_spain.65.t
	desc = lar_spain.65.desc
	picture = GFX_report_event_spr_no_pasaran
	
	is_triggered_only = yes
	option = { # Ok
		name = lar_spain.65.a
		effect_tooltip = { FROM = { add_opinion_modifier = { target = ROOT modifier = SPA_spanish_civil_war_commitments } } }
		add_war_support = 0.15
	}
}

# Petition for French Aid - Event for Spain - France Declined
country_event = {
	id = lar_spain.66
	title = lar_spain.66.t
	desc = lar_spain.66.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.66.a
	}
}

# War of Independence - Event for SOV
country_event = {
	id = lar_spain.67
	title = lar_spain.67.t
	desc = lar_spain.67.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			end_puppet = FROM
			remove_from_faction = FROM
		}
	}
	
	option = { # Ok
		name = lar_spain.67.a
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.33
				any_country = {
					is_major = yes
					has_war_with = ROOT
				}
			}
			modifier = {
				factor = 0
				surrender_progress > 0.1
			}
		}
		effect_tooltip = {
			end_puppet = FROM
			remove_from_faction = FROM
		}
		FROM = {
			declare_war_on = {
			    target = ROOT
			    type = topple_government
			}
		}
		hidden_effect = { FROM = { news_event = { id = lar_news.20 hours = 6 } } }
	}

	option = { # Let them have their independence
		name = lar_spain.67.b
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				any_country = {
					is_major = yes
					has_war_with = ROOT
				}
			}
			modifier = {
				add = 100
				has_country_flag = SOV_give_them_independence_flag
			}
		}
		effect_tooltip = {
			end_puppet = FROM
			remove_from_faction = FROM
		}
		delete_unit_template_and_units = {
			division_template = "Spanish Loyalist Division"
		}
		if = {
			limit = {
				has_country_flag = SOV_annexed_spanish_land
			}
			FROM = {
				transfer_state = 165
				transfer_state = 167
				transfer_state = 794
			}
		}
		FROM = { country_event = lar_spain.89 }
	}
}

# Those Who Would Not Help Us - Event for USA/ENG/FRA
country_event = {
	id = lar_spain.68
	title = lar_spain.68.t
	desc = lar_spain.68.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.68.a
		ai_chance = {
			base = 75
		}
		add_timed_idea = { idea = SPR_equipment_shipments days = 730 }
		add_ai_strategy = { type = send_lend_lease_desire id = SPR value = 100 }
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.69 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.68.b
		ai_chance = {
			base = 25
			modifier = {
				factor = 0.5
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0
				has_war_with = SOV
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.70 }
			}
		}
	}
}

# Those Who Would Not Help Us - Event for Spain - FROM Accepted
country_event = {
	id = lar_spain.69
	title = lar_spain.69.t
	desc = lar_spain.69.desc
	picture = GFX_report_event_generic_sign_treaty1
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.69.a
		effect_tooltip = {
			FROM = { add_timed_idea = { idea = SPR_equipment_shipments days = 730 } }
		}
	}
}

# Those Who Would Not Help Us - Event for Spain - FROM Declined
country_event = {
	id = lar_spain.70
	title = lar_spain.70.t
	desc = lar_spain.70.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.70.a
	}
}

# Enemies of Our Enemy - Event for GER/ITA
country_event = {
	id = lar_spain.71
	title = lar_spain.71.t
	desc = lar_spain.71.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.71.a
		ai_chance = {
			base = 75
		}
		diplomatic_relation = {
		    country = FROM
		    relation = non_aggression_pact
		    active = yes
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.72 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.71.b
		ai_chance = {
			base = 25
			modifier = {
				factor = 0.5
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0
				has_war_with = SOV
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.73 }
			}
		}
	}
}

# Enemies of Our Enemy - Event for Spain - FROM Accepted
country_event = {
	id = lar_spain.72
	title = lar_spain.72.t
	desc = lar_spain.72.desc
	picture = GFX_report_event_generic_sign_treaty3
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.72.a
		effect_tooltip = {
			FROM = {
				diplomatic_relation = {
				    country = ROOT
				    relation = non_aggression_pact
				    active = yes
				}
			}
		}
	}
}

# Enemies of Our Enemy - Event for Spain - FROM Declined
country_event = {
	id = lar_spain.73
	title = lar_spain.73.t
	desc = lar_spain.73.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.73.a
	}
}

# Enemies of Our Enemy - Event for GER
country_event = {
	id = lar_spain.74
	title = lar_spain.74.t
	desc = lar_spain.74.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Accept
		name = lar_spain.74.a
		ai_chance = {
			base = 75
		}
		army_experience = -25
		effect_tooltip = {
			FROM = {
				add_timed_idea = { idea = SPR_deal_with_the_devil days = 730 }
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.75 }
			}
		}
	}

	option = { # Decline
		name = lar_spain.74.b
		ai_chance = {
			base = 25
			modifier = {
				factor = 0.5
				has_opinion = { target = FROM value > 99 }
			}
			modifier = {
				factor = 0
				has_war_with = SOV
			}
		}
		hidden_effect = {
			FROM = {
				country_event = { id = lar_spain.76 }
			}
		}
	}
}

# Enemies of Our Enemy - Event for Spain - FROM Accepted
country_event = {
	id = lar_spain.75
	title = lar_spain.75.t
	desc = lar_spain.75.desc
	picture = GFX_report_event_generic_sign_treaty2
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.75.a
		add_timed_idea = { idea = SPR_deal_with_the_devil days = 730 }
	}
}

# Enemies of Our Enemy - Event for Spain - FROM Declined
country_event = {
	id = lar_spain.76
	title = lar_spain.76.t
	desc = lar_spain.76.desc
	picture = GFX_report_event_generic_read_write
	
	is_triggered_only = yes
	
	option = { # Damn
		name = lar_spain.76.a
	}
}

# Spain - Alfonso Dies
country_event = {
	id = lar_spain.77
	title = lar_spain.77.t
	desc = {
		text = lar_spain.77.desc1
		trigger = {
			has_completed_focus = SPA_restore_the_monarchy
			NOT = { has_country_flag = SPB_xavier_king }
		}
	}
	desc = {
		text = lar_spain.77.desc2
		trigger = {
			NOT = {
				AND = {
					has_completed_focus = SPA_restore_the_monarchy
					NOT = { has_country_flag = SPB_xavier_king }
				}
			}
		}
	}
	picture = GFX_report_event_europe_funeral
	
	trigger = {
		original_tag = SPR
		if = {
			limit = {
				any_country = {
					OR = {
						AND = {
							tag = SPA
							has_completed_focus = SPA_unify_the_nationalist_front
						}
						tag = SPB
					}
					is_ai = no
				}
			}
			is_ai = no
		}
		has_completed_focus = SPA_a_great_spain
		NOT = { has_completed_focus = SPA_the_phalanx_ascendant }
		NOT = { has_global_flag = SPB_alfonso_xiii_dead }
		date > 1940.2.28
	}

	mean_time_to_happen = {
		days = 365
	}

	fire_only_once = yes

	immediate = {
		hidden_effect = {
			set_global_flag = SPB_alfonso_xiii_dead
			if = {
				limit = {
					has_country_leader = {
					    name = "Alfonso XIII"
					    ruling_only = yes
					}
				}
				kill_country_leader = yes
				create_country_leader = {
					name = "Jaime IV"
					desc = "POLITICS_JAIME_IV_DESC"
					picture = "GFX_portrait_fra_infante_jaime"
					expire = "1965.1.1"
					ideology = despotism
					traits = {
						
					}
				}
			}
		}
	}
	
	option = { # RIP
		name = lar_spain.77.a
		if = {
			limit = {
				has_country_leader = {
				    name = "Alfonso XIII"
				    ruling_only = yes
				}
			}
			effect_tooltip = {
				kill_country_leader = yes
				create_country_leader = {
					name = "Jaime IV"
					desc = "POLITICS_JAIME_IV_DESC"
					picture = "GFX_portrait_fra_infante_jaime"
					expire = "1965.1.1"
					ideology = despotism
					traits = {
						
					}
				}
			}
		}
	}
}

# Spain - Sanjurjo Dies
country_event = {
	id = lar_spain.78
	title = lar_spain.78.t
	desc = lar_spain.78.desc
	picture = GFX_report_event_spr_plane_crash
	
	is_triggered_only = yes
	
	immediate = {
		hidden_effect = {
			kill_country_leader = yes
			create_country_leader = {
				name = "Military Junta"
				desc = "POLITICS_MILITARY_JUNTA_DESC"
				picture = "GFX_portrait_SPA_military_junta"
				expire = "1965.1.1"
				ideology = despotism
				traits = {
					divided_interests
				}
			}
		}
	}
	
	option = { # RIP
		name = lar_spain.78.a
		effect_tooltip = {
			custom_effect_tooltip = lar_spain.78_tt
			hidden_effect = {
				kill_country_leader = yes
			}
			create_country_leader = {
				name = "Military Junta"
				desc = "POLITICS_MILITARY_JUNTA_DESC"
				picture = "GFX_portrait_SPA_military_junta"
				expire = "1965.1.1"
				ideology = despotism
				traits = {
					divided_interests
				}
			}
		}
	}
}

# Claim the French Throne - Event for Spain - Coronation
country_event = {
	id = lar_spain.79
	title = lar_spain.79.t
	desc = lar_spain.79.desc
	picture = GFX_report_event_royal_parade
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.79.a
		FRA = {
			every_unit_leader = {
				set_nationality = ROOT
			}
		}
		every_state = {
			limit = {
				is_core_of = FRA
			}
			add_core_of = ROOT
		}
		annex_country = { target = FRA transfer_troops = yes }
	}
}

# Hidden event to 'age' Franco after 1950
country_event = {
	id = lar_spain.80

	trigger = {
		tag = SPA
		has_completed_focus = SPA_caudillo_of_spain
		NOT = { has_completed_focus = SPA_restore_the_monarchy }
		date > 1950.1.1
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes

	hidden = yes

	immediate = {
		hidden_effect = {
			SPA_francisco_franco = {
				set_portraits = {
					civilian = { large =  GFX_portrait_spain_francisco_franco_old }
				}
			}
		}
	}
}

# End of SCW, Republicans expanded Soviet aid - event for SOV
country_event = {
	id = lar_spain.81
	title = lar_spain.81.t
	desc = lar_spain.81.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes
	
	option = { # Ok
		name = lar_spain.81.a
		effect_tooltip = {
			puppet = SPD
		}
	}
}

# End of SCW, Republicans expanded Soviet aid - event for SPD
country_event = {
	id = lar_spain.82
	title = lar_spain.82.t
	desc = lar_spain.82.desc
	picture = GFX_report_event_generic_parliament
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					has_government = democratic
				}
				set_country_flag = SPR_democratic_government_flag
			}
			set_temp_variable = {
				var = soviet_puppet_democratic_var
				value = party_popularity@democratic
			}
			SOV = { puppet = SPD }
			if = {
				limit = {
					has_country_flag = SPR_democratic_government_flag
				}
				set_politics = {
					ruling_party = democratic
				}
				clr_country_flag = SPR_democratic_government_flag
			}
			set_political_party = {
			    ideology = communism
			    popularity = 100
			}
			add_popularity = {
			    ideology = democratic
			    popularity = soviet_puppet_democratic_var
			}
		}
	}
	
	option = { # Ok
		name = lar_spain.82.a
		effect_tooltip = {
			SOV = { puppet = SPD }
		}
	}
}

# Soviets get notification SPR is being disloyal
country_event = {
	id = lar_spain.83
	title = lar_spain.83.t
	desc = lar_spain.83.desc
	picture = GFX_report_event_generic_parliament

	trigger = {
		tag = SOV
		any_country = {
			original_tag = SPR
			focus_progress = {
			    focus = SPR_subvert_soviet_control
			    progress > 0.1
			}
		}
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes

	option = { # We must act!
		name = lar_spain.83.a
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.33
				any_country = {
					is_major = yes
					has_war_with = ROOT
				}
			}
			modifier = {
				factor = 0
				surrender_progress > 0.1
			}
		}
		set_country_flag = SOV_annexed_spanish_land
		transfer_state = 165
		transfer_state = 167
		transfer_state = 794
		hidden_effect = { SPD = { country_event = { id = lar_spain.84 } } }
		division_template = {
			name = "Spanish Loyalist Division"
			priority = 1
			division_names_group = SOV_INF_01
			is_locked = yes
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }
			}
		}
		# Catalonia
		165 = {
			create_unit = {
				division = "name = \"1. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"2. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
		}
		# Valencia
		167 = {
			create_unit = {
				division = "name = \"3. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"4. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"5. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"6. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"7. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
		}
		 # Eastern Aragon
		794 = {
			create_unit = {
				division = "name = \"8. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"9. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"10. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"11. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"12. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"13. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"14. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"15. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
			create_unit = {
				division = "name = \"16. Spanish Loyalist Division\" division_template = \"Spanish Loyalist Division\" start_experience_factor = 0.1" 
				owner = ROOT
			}
		}
	}

	option = { # Everything will be fine
		name = lar_spain.83.b
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				any_country = {
					is_major = yes
					has_war_with = ROOT
				}
			}
		}
		set_country_flag = SOV_give_them_independence_flag
		add_political_power = -50
	}
}

# Event for SPR that Soviets are seizing land
country_event = {
	id = lar_spain.84
	title = lar_spain.84.t
	desc = lar_spain.84.desc
	picture = GFX_report_event_soviet_army_greeted

	is_triggered_only = yes

	option = { # Bastards!
		name = lar_spain.84.a
		set_country_flag = SOV_took_spanish_states
		effect_tooltip = {
			SOV = {
				transfer_state = 165
				transfer_state = 167
				transfer_state = 794
			}
		}
	}
}

# SPR has Catalonia returned
country_event = {
	id = lar_spain.85
	title = lar_spain.85.t
	desc = lar_spain.85.desc
	picture = GFX_report_event_soldiers_marching

	trigger = {
		tag = SPD
		has_completed_focus = SPR_war_of_independence
		has_country_flag = SOV_took_spanish_states
		has_war_with = SOV
		SOV = { owns_state = 165 }
		has_full_control_of_state = 165
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes

	immediate = {
		hidden_effect = {
			165 = { save_event_target_as = SPR_stolen_state_name }
		}
	}

	option = { # Excellent!
		name = lar_spain.85.a
		transfer_state = 165
		hidden_effect = { SOV = { country_event = { id = lar_spain.88 } } }
	}
}

# SPR has Valencia returned
country_event = {
	id = lar_spain.86
	title = lar_spain.85.t
	desc = lar_spain.85.desc
	picture = GFX_report_event_soldiers_marching

	trigger = {
		tag = SPD
		has_completed_focus = SPR_war_of_independence
		has_country_flag = SOV_took_spanish_states
		has_war_with = SOV
		SOV = { owns_state = 167 }
		has_full_control_of_state = 167
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes

	immediate = {
		hidden_effect = {
			167 = { save_event_target_as = SPR_stolen_state_name }
		}
	}

	option = { # Excellent!
		name = lar_spain.85.a
		transfer_state = 167
		hidden_effect = { SOV = { country_event = { id = lar_spain.88 } } }
	}
}

# SPR has Eastern Aragon returned
country_event = {
	id = lar_spain.87
	title = lar_spain.85.t
	desc = lar_spain.85.desc
	picture = GFX_report_event_soldiers_marching

	trigger = {
		tag = SPD
		has_completed_focus = SPR_war_of_independence
		has_country_flag = SOV_took_spanish_states
		has_war_with = SOV
		SOV = { owns_state = 794 }
		has_full_control_of_state = 794
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes

	immediate = {
		hidden_effect = {
			794 = { save_event_target_as = SPR_stolen_state_name }
		}
	}

	option = { # Excellent!
		name = lar_spain.85.a
		transfer_state = 794
		hidden_effect = { SOV = { country_event = { id = lar_spain.88 } } }
	}
}

# Event for SOV informing them of losing a state to SPR
country_event = {
	id = lar_spain.88
	title = lar_spain.88.t
	desc = lar_spain.88.desc
	picture = GFX_report_event_soldiers_marching

	is_triggered_only = yes

	option = { # Excellent!
		name = lar_spain.88.a
		effect_tooltip = { FROM = { transfer_state = event_target:SPR_stolen_state_name } }
	}
}

# Event for SPR that Soviets are giving them independence
country_event = {
	id = lar_spain.89
	title = lar_spain.89.t
	desc = lar_spain.89.desc
	picture = GFX_report_event_soviet_army_greeted

	is_triggered_only = yes

	option = { # Ok
		name = lar_spain.89.a
		if = {
			limit = {
				SOV = { has_country_flag = SOV_annexed_spanish_land }
			}
			SOV = { clr_country_flag = SOV_annexed_spanish_land }
			effect_tooltip = {
				FROM = {
					transfer_state = 165
					transfer_state = 167
					transfer_state = 794
				}
			}
		}
	}
}

# Event for Spain that the president is dismissed
country_event = {
	id = lar_spain.90
	title = lar_spain.90.t
	desc = lar_spain.90.desc
	picture = GFX_report_event_generic_parliament

	trigger = {
		tag = SPR
		date > 1936.4.20
		NOT = { has_global_flag = spanish_civil_war }
	}

	mean_time_to_happen = {
		days = 2
	}

	fire_only_once = yes

	option = { # Ok
		name = lar_spain.90.a
		if = {
			limit = {
				has_dlc = "La Resistance"
			}
			if = {
				limit = {
					has_completed_focus = SPR_the_popular_front
				}
				remove_ideas = SPR_government_power_struggle
				add_political_power = 10
			}
			retire_country_leader = yes
			add_country_leader_role = {
				character = SPR_manuel_azana
				country_leader = {
				 	ideology = conservatism
				 	traits = { figurehead_president }
				 	expire = "1965.1.1"
				}
				promote_leader = yes
			}
		}
		else = {
			retire_country_leader = yes
			add_country_leader_role = {
				character = SPR_manuel_azana
				country_leader = {
				 	ideology = conservatism
				 	traits = { }
				 	expire = "1965.1.1"
				}
				promote_leader = yes
			}
		}
	}
}


# Spain unites the Hispanics!
news_event = {
	id = lar_spain.100
	title = lar_spain.100.t
	desc = lar_spain.100.d
	picture = GFX_news_event_journalists_speech
	
	major = yes
	
	is_triggered_only = yes
	
	option = {
		name = lar_spain.100.a
		trigger = {
			NOT = {
				original_tag = SPR
			}
		}
	}
	option = {
		name = lar_spain.100.b
		trigger = { original_tag = SPR }
	}
} 
